Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting QWindow back into parent QWidget from the fullscreen
Qt 6.12 LTS is out! See what's new in the release blog

Getting QWindow back into parent QWidget from the fullscreen

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 3 Posters 10.6k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Since you are using layouts, you should first remove your widget from the layout, then do what you want and at the end put the widget back in the layout.

    Hope it helps

    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
    • S Offline
      S Offline
      sasmaster
      wrote on last edited by sasmaster
      #3

      It doesn't work. No matter what I do when exiting the fullscreen mode, an error thrown:

      Program: D:\Qt\5.9.1\msvc2015_64\bin\Qt5Cored.dll
      Module: 5.9.1
      File: global\qglobal.cpp
      Line: 3049
      ASSERT: "toplevel->windowHandle()" in file kernel\qwindowcontainer.cpp, line 380

      Again,here is what I do when going full screen:

      vbox->removeWidget(myWinContainer);
      myWinContainer->setParent(this,Qt::Tool);//also tried setParent(nullptr)
      myWinContainer->showFullScreen();
      

      And getting back to normal mode:

      myWinContainer->setWindowState(Qt::WindowNoState);
      vbox->insertWidget(0,myWinContainer);
      myWinContainer->showNormal(); //crashes here with above error
      

      I feel like there is a bug at the level of qwindowcontainer.Because no matter what method I call on the QWindow instances owned by myWinContainer, it leads to the crash with the error above

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

        Can you provide a minimal compilable example that shows that behaviour ?

        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
        • S Offline
          S Offline
          sasmaster
          wrote on last edited by
          #5

          Yes,sure.

          Inside MainWindow (QMainWindow):

          myWindow = new MyWindow(); // inherits from QWindow
          myWinContainer= QWidget::createWindowContainer(myWindow ,this);
          myWinContainer->setFixedSize(640,360);
          //layouts:
          vbox = new QVBoxLayout();
          vbox->setAlignment(Qt::AlignHCenter);
          vbox->addWidget(myWinContainer);
          ui->centralWidget->setLayout(vbox);
          

          Slot that enters/exits fullscreen mode for myWinContainer:

              if( myWinContainer->windowState() == Qt::WindowFullScreen )
              {
                  myWinContainer->setParent(this);
                  myWinContainer->setWindowState(Qt::WindowNoState);
                  vbox->insertWidget(0,myWinContainer);
              }
              else
              {
                  vbox->removeWidget(myWinContainer);
                  //  myWinContainer->setParent(nullptr);//doesn't help either
                  myWinContainer->setParent(this,Qt::Tool);
                  myWinContainer->showFullScreen();
              }
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            That's not a compilable example.

            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
            • S Offline
              S Offline
              sasmaster
              wrote on last edited by sasmaster
              #7

              Hey SGaist,Here is a complete runnable program with the problem.Thanks![0_1504612576256_FullScrTest.rar](Uploading 100%)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sasmaster
                wrote on last edited by
                #8

                Oops,it appears I don't have enough privilege to upload files. How do I pass the code to you?

                mrjjM 1 Reply Last reply
                0
                • S sasmaster

                  Oops,it appears I don't have enough privilege to upload files. How do I pass the code to you?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @sasmaster
                  Hi
                  it dont like some files. ( not for anyone at all )

                  If possible use googledrive/dropbox or Github etc.

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    sasmaster
                    wrote on last edited by
                    #10

                    Hmm,indeed, DropBox is the option... Here is the link to the test prog that show the issue:
                    https://www.dropbox.com/s/dxow1ye9fo6r1ap/FullScrTest.rar?dl=0

                    Thanks.

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

                      I don't know whether you are hitting an unusual code path or if there's really a bug. You should check the bug report system to see if there's something related.

                      In any case, since you are doing OpenGL with widgets, did you consider using QOpenGLWidget ?

                      On a side note, there's QOpenGLWindow that might also interest you.

                      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
                      • S Offline
                        S Offline
                        sasmaster
                        wrote on last edited by sasmaster
                        #12

                        If you check the code you see that the full screen problem error has no relation to OpenGL at all. What I see here is SDK bug. The reason I don't use any sort of widget is because I don't need all the pile of code which comes with QWidget. All I need is a thin GL surface to render to very very fast.So I guess that I need to file a bug?

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

                          What I see is that the assert comes from QWindowContainer which for some reason can't get a window handle from the top level widget. Hence my question whether you are hitting an unusual code path using QWindow as you do.

                          If you don't want widgets, then why are you using a QMainWindow ?

                          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
                          • S Offline
                            S Offline
                            sasmaster
                            wrote on last edited by
                            #14

                            I do need widgets for some UI around the rendering window.
                            "Hence my question whether you are hitting an unusual code path using QWindow as you do" - what do you mean by that?

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

                              Simply that I don't know whether the top level widget handling works as expected and you are doing something wrong with your QWindow or if in fact you uncovered a use case not handled properly.

                              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
                              • S Offline
                                S Offline
                                sasmaster
                                wrote on last edited by
                                #16

                                And therefore I uploaded for you a full program depicting the use case. Have you tested it?

                                mrjjM 1 Reply Last reply
                                0
                                • S sasmaster

                                  And therefore I uploaded for you a full program depicting the use case. Have you tested it?

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  @sasmaster

                                  Hi i did run it on win 10, Qt 5.9/Qt 5.5 and
                                  did have it crash consistently.
                                  Also i removed much of the openGL code and seems not related to that at all unless
                                  its some sort of hidden use or something i missed.

                                  It does smells like a (Qt) bug but I didn't get 100% proof.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    sasmaster
                                    wrote on last edited by
                                    #18

                                    Hi mrjj. Thanks for your input. If QT CHAMPION says it smells like a bug, then probably it's a bug :)

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

                                      Yes I did after having to remove some stuff to make it start like @mrjj did.

                                      Hence you can also mention that the problem appears on macOS 10.12.6.

                                      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
                                      1
                                      • S Offline
                                        S Offline
                                        sasmaster
                                        wrote on last edited by
                                        #20

                                        Thanks for collaboration, guys. Submitted a bug:
                                        https://bugreports.qt.io/browse/QTBUG-63168

                                        1 Reply Last reply
                                        1

                                        • Login

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