Design of Layout

  • I have ten buttons on a Qlabel.i want to align 5 buttons to top left and 5 buttons to center bottom

    so i create a Qhorizontaltab to save topleft button and assign it

    @horizontaltab=new QHBoxLayout(label);
    horizontaltab->setAlignment(Qt::AlignLeft|Qt::AlignTop); @

    and other buttons are added to another horizontal layout
    @horizontal=new QHBoxLayout(label);
    horizontal->setAlignment(Qt::Aligncenter|Qt::AlignBottom); @

    Now how can i add another layout to save these two layouts?

  • Ok,
    Are you using designer? If not, please, do use it, then check out the ui file code how it is done.

  • Fine .it would be helpful if i could simply write a code.becuase i never use Ui designer

  • Hi, I'm not saying you should utilize designer in your design, but it gives good example what is possible with standard Qt GUI design widgets.
    But here goes:

    • place the 5 buttons both in horizontal layout (you already did this)
    • place those layouts in a gridlayout or maybe matrixlayout
    • Add spacers on the left and right side of it when you to centre the buttons
    • Add spacers to the right side of the buttons to left align them.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.