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. how to resize Widget in stackedLayout?
Forum Updated to NodeBB v4.3 + New Features

how to resize Widget in stackedLayout?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 3.5k 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.
  • Q Offline
    Q Offline
    qtpi
    wrote on last edited by
    #1

    hi folks, I'm trying to make a overlapping widget, in which a label and a sub-classed widget showing on on another at the same time.

    the problem is I want to change the background color of the label, then I found the size of the label is actually the whole qstackedlayout. I tried to resize the label to make it smaller and didn't work. tried to add another layout and found addlayout is actually not a member function of QStackedLayout.

    what to do? thanks you guys in advance!

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

      Hi,

      If you want to overlap two widgets you have to position the top widget yourself over the other one. A QStackedLayout allows you to have several widgets at the same place at the same time but only one will be visible at a time.

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

      Q 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        If you want to overlap two widgets you have to position the top widget yourself over the other one. A QStackedLayout allows you to have several widgets at the same place at the same time but only one will be visible at a time.

        Q Offline
        Q Offline
        qtpi
        wrote on last edited by
        #3

        @SGaist said:

        self over the other one. A QStackedLayout allows you to have several widgets at the same place at the same time but only one will

        hi SGaist, I set QStackedLayout::StackAll. it allows all the widgets show at the same time.

        but my problem is once I tried to change the background color of one widget, but I found the size of the label is the whole stackedlayout...

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

          Right, I forgot about StackAll, thanks for the reminder.

          But still, a layout will handle the size and position of the widget, since you want yours to float at a precise position, do the positioning yourself.

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

          Q 1 Reply Last reply
          0
          • SGaistS SGaist

            Right, I forgot about StackAll, thanks for the reminder.

            But still, a layout will handle the size and position of the widget, since you want yours to float at a precise position, do the positioning yourself.

            Q Offline
            Q Offline
            qtpi
            wrote on last edited by
            #5

            @SGaist yea...the problem is it seems I cannot change the size of the widget in stackedlayout...is it normal? the widget just covers automatically the whole stackedlayout.

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

              Yes it is normal. A layout manager does that: it position and resize the widgets you put in so you don't have to do everything by hand. It will adapt as needed when you resize the widget on which you applied the layout.

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

              Q 1 Reply Last reply
              0
              • SGaistS SGaist

                Yes it is normal. A layout manager does that: it position and resize the widgets you put in so you don't have to do everything by hand. It will adapt as needed when you resize the widget on which you applied the layout.

                Q Offline
                Q Offline
                qtpi
                wrote on last edited by
                #7

                @SGaist aha. that's why...

                but is there a way to resize one of the widget in this case? I tried to add another layout(QHBoxLayout) into stackedlayout and it didn't work.

                it seems it's impossible to resize it in a stackedlayout....in QHBoxlayout at least you can use addStrech function.

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

                  Where exactly would you like that widget to appear ?

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

                  Q 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Where exactly would you like that widget to appear ?

                    Q Offline
                    Q Offline
                    qtpi
                    wrote on last edited by qtpi
                    #9

                    @SGaist so I made a widget in which a picture is rotating. A label is much smaller and will overlap on the widget. They are combined in a qstackedlayout. So I want to change the background color of the label when the rotation of the bigger widget reaches some level.

                    but as I said the background of the label covers acutually the whole qstackedlayout. that's kinda annoying. I have placed the label in the middle with setAlignment. Only wish is to resize the label , which seems to be incredibly hard.

                    so the whole object should look like two concentric circles. I want to change the color of the inner circle without changing the color of the outer circle.

                    I hope I have explained it in a proper way.

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

                      Sounds like something for the Graphics View Framework

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

                      Q 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        Sounds like something for the Graphics View Framework

                        Q Offline
                        Q Offline
                        qtpi
                        wrote on last edited by
                        #11

                        @SGaist thnx so much for the help man imma check it out.

                        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