Implementing a FullScreen Toggle using QWindow inside of a WindowContainer which is inside of a QMainWindow



  • Hello,

    I hope the title explains the jist of what I am trying to do. What I want is this:

    You hit F11 on the keyboard and the application toggles fullscreen. Seems simple.

    Right now my application consists of my OpenGL environment which is implemented with a QWindow housed inside of a QWidget::createWindowContainer().

    The container is then placed inside of a QMainWindow.

    While the application is running the QWindow takes focus but I don't know how to get access to the QMainWindow to toggle it full screen when I need to and then shrink back down to normal from a key event.

    Any ideas?

    Thank you.



  • Perhaps I have answered my own question.

    This works.

    Can the below code be optimized? I just want the QMainWindow to be affected:

    @
    if (ev->key() == Qt::Key_F11) {

    FullScreen = !FullScreen;

    if (FullScreen) {

    foreach(QWidget *widget, QApplication::topLevelWidgets()) {
    if (widget->isWindow())
    widget->showFullScreen();
    }

    }
    else {

    foreach(QWidget *widget, QApplication::topLevelWidgets()) {
    if (widget->isWindow())
    widget->showNormal();
    }

    }

    }
    @


  • Lifetime Qt Champion

    Hi,

    What about using an eventFilter ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.