Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen widget

How can I make my widget fullscreen? I've tried something like this:

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();
}

But widget isn't over system panels. Any another ideas?

OS: Linux

like image 760
Max Frai Avatar asked Aug 07 '09 20:08

Max Frai


2 Answers

QWidget::showFullScreen() is what you need - works great under Linux+Windows in my projects for years - but be careful, there shouldn't be two calls of this function (eg. first call of QMainWindo->showFullScreen() and then MyWidget->showFullScreen()).

ciao, Chris

like image 181
3DH Avatar answered Sep 29 '22 19:09

3DH


This code will allow you to set a full screen by double clicking and to return back to the normal view by double clicking again.

void myWidget::mouseDoubleClickEvent(QMouseEvent *e) {
  QWidget::mouseDoubleClickEvent(e);
  if(isFullScreen()) {
     this->setWindowState(Qt::WindowMaximized);
  } else {
     this->setWindowState(Qt::WindowFullScreen);
  }
}
like image 32
Sputnik Avatar answered Sep 29 '22 19:09

Sputnik