2009-08-07 3 views
37

위젯을 전체 화면으로 만들려면 어떻게해야합니까? 나는 이런 식으로 시도했다 :전체 화면 위젯

void MainWindow::SetFullScreen() 
{ 
    // Make our window without panels 
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint); 
    // Resize refer to desktop 
    this->resize(QApplication::desktop()->size()); 

    this->setFocusPolicy(Qt::StrongFocus); 
    this->setAttribute(Qt::WA_QuitOnClose, true); 

    qApp->processEvents(); 
    show(); 
    this->setFocus(); 
} 

그러나 위젯은 시스템 패널을 초과하지 않는다. 다른 아이디어?

OS : (이 함수의 두 통화가 안된다,하지만 조심 예를 들어 QMainWindo->showFullScreen()의 첫 번째 호출 - 리눅스

답변

52

QWidget::showFullScreen()는 당신이 필요로하는 무엇을 - 년 내 프로젝트에 리눅스 + Windows에서 잘 작동합니다. 그런 다음 MyWidget->showFullScreen()).

챠오, 크리스

+0

감사합니다. 크게 작동합니다! – Ockonal

+4

"MyWidget"이 다른 창인 경우를 제외하고 MyWidget-> showFullScreen()은 아무 것도하지 않습니다. –

+0

XRandr, Eyefinity 또는 Xinerama로 여러 화면을 설정하는 방법은 어떻습니까? 제대로 작동합니까? – drahnr

8

이 코드는 당신이 두 번 클릭하여 전체 화면을 설정할 수 있도록하고 다시 두 번 클릭하여 다시 정상보기로 돌아갑니다.

void myWidget::mouseDoubleClickEvent(QMouseEvent *e) { 
    QWidget::mouseDoubleClickEvent(e); 
    if(isFullScreen()) { 
    this->setWindowState(Qt::WindowMaximized); 
    } else { 
    this->setWindowState(Qt::WindowFullScreen); 
    } 
}