Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Implementing a FullScreen Toggle using QWindow inside of a WindowContainer which is inside of a QMainWindow

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tmason101
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tmason101
      wrote on last edited by
      #2

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

      }

      }
      @

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What about using an eventFilter ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved