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. auto resizing stackedwidget and children
Qt 6.11 is out! See what's new in the release blog

auto resizing stackedwidget and children

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 3.9k 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.
  • J Offline
    J Offline
    John Green
    wrote on last edited by
    #1

    I'm using the qt designer with a QMainWindow and in that a QWidget contained a QStackedWidget so my program can have several different widgets. The problem I'm having is getting things to resize with the QMainWindow, it seems anything inside the QStackedWidget doesn't resize with the window, how can I fix this?

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

      Hi,

      Did you put that QStackedWidget as your QMainWindow central widget ?

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

      J 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Did you put that QStackedWidget as your QMainWindow central widget ?

        J Offline
        J Offline
        John Green
        wrote on last edited by
        #3

        @SGaist no the hierarchy is MainWindow->centralWidget->stackedWidget

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

          In that case, either replace the central widget with the QStackedWidget, or put a layout on the central widget and the QStackedWidget in that layout.

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

          J 1 Reply Last reply
          1
          • SGaistS SGaist

            In that case, either replace the central widget with the QStackedWidget, or put a layout on the central widget and the QStackedWidget in that layout.

            J Offline
            J Offline
            John Green
            wrote on last edited by
            #5

            @SGaist putting a layout on both does allow resizing but I'm unable to place things where I wan't them, they just lock to a certain position and If i try move them they just go back to that position

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

              You can build complex layouts to do what you want.

              If you really want to manage all by hand then you have to also re-implement the resize event of your "container" widgets to update the size and postions of their children.

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

              J 1 Reply Last reply
              0
              • SGaistS SGaist

                You can build complex layouts to do what you want.

                If you really want to manage all by hand then you have to also re-implement the resize event of your "container" widgets to update the size and postions of their children.

                J Offline
                J Offline
                John Green
                wrote on last edited by
                #7

                @SGaist any suggestions where to learn this?

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

                  Do you mean learn the use of layouts ?

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

                  J 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Do you mean learn the use of layouts ?

                    J Offline
                    J Offline
                    John Green
                    wrote on last edited by
                    #9

                    @SGaist learn how to make the complex layouts, because as far as I'm aware I've looked over the documentation and I still can't create a custom layout how I wan't. I just need pages that when the user resizes so does every child widget on that page, but I also wan't to be able to place the widgets where I wan't

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

                      Can you show an example of such a widget ?

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

                      J 1 Reply Last reply
                      2
                      • SGaistS SGaist

                        Can you show an example of such a widget ?

                        J Offline
                        J Offline
                        John Green
                        wrote on last edited by John Green
                        #11

                        @SGaist
                        This is what i have, need to add stuff like buttons and qlineedits to the login page to get user inputs. Need them to resize when the user resizes the window0_1552427791535_delete.png

                        1 Reply Last reply
                        0
                        • mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Hi
                          With GridLayout, you can resize the widgets by dragging the handles while in layout
                          alt text
                          However, as name suggest its a grid so there needs to be some alignment.

                          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 Extensions
                          • Unsolved