Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    [SOLVED] Help with reversing the functionality of QVBoxLayout

    General and Desktop
    3
    5
    1619
    Loading More Posts
    • 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
      holygirl last edited by

      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 Reply Quote 0
      • H
        holygirl last edited by

        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 Reply Quote 0
        • T
          tzander last edited by

          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 Reply Quote 0
          • B
            b1gsnak3 last edited by

            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 Reply Quote 0
            • H
              holygirl last edited by

              [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 Reply Quote 0
              • First post
                Last post