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. [SOLVED] Help with reversing the functionality of QVBoxLayout

[SOLVED] Help with reversing the functionality of QVBoxLayout

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.1k Views
  • 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.
  • H Offline
    H Offline
    holygirl
    wrote on last edited by
    #1

    Hey people!

           I know that adding widgets to _QVBoxLayout_ aligns the widgets vertically one after the other.
    

    @
    QVBoxLayout *vbl = new QVBoxLayout();
    vbl->addWidget(label1, 0, Qt::AlignBottom);
    vbl->addWidget(label2, 0, Qt::AlignBottom);
    vbl->addWidget(label3, 0, Qt::AlignBottom);
    @

    This results in the labels being aligned in the following sequence

    label1
    label2
    label3

    Now, if I want to start adding widgets from bottom to top so the sequence is like

    label3
    label2
    label1

    How do I do it? I add widgets to the layout dynamically and I want them to be stacked one above the other. Please help!
    Thanks.

    EDIT: I just read about BottomToTop. Trying to figure out how to use it

    1 Reply Last reply
    0
    • H Offline
      H Offline
      holygirl
      wrote on last edited by
      #2

      Sorry guys. I figured out the answer minutes after posting this question. Anyway, for those who might need help to this question,

      @ mainlayout->setDirection(QBoxLayout::BottomToTop);@

      This will change the direction of the BoxLayout. "This":http://doc.qt.digia.com/stable/qboxlayout.html#Direction-enum should help for further information.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tzander
        wrote on last edited by
        #3

        This looks like a 'rubber-duck' solution :P
        http://en.wikipedia.org/wiki/Rubber_duck_debugging

        Maybe you can change the topic of the first post to include '[Solved]' ?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          b1gsnak3
          wrote on last edited by
          #4

          or you could have just added the labels with label3 first :) seems like a much easier solution (especially when you have more stuff in the layout)

          1 Reply Last reply
          0
          • H Offline
            H Offline
            holygirl
            wrote on last edited by
            #5

            [quote author="b1gsnak3" date="1360307539"]or you could have just added the labels with label3 first :) seems like a much easier solution (especially when you have more stuff in the layout[/quote]

            That was not possible because I'll be adding the labels dynamically based on the user input. So they might layer in any order like label1, label2, label3 or label3, label1, label2 etc. I want this layer to happen from bottom to top so it looks like the labels are sitting at the bottom of the screen.

            Bah! I know that was a horrible explanation of what I'm trying to do. Hope you could understand.

            [quote author="Thomas Zander" date="1360306620"]This looks like a 'rubber-duck' solution :P[/quote]

            I laughed so hard reading that link. I can't imagine myself talking to a rubber duck. Hahaha! :)

            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