Attach button and other widgets to the right side of the parent widget, on resize.



  • Hello,
    I'm using Qt5.6, for an UI widgets desktop application, on windows platform.
    I want to attach pushbuttons to the right side of the frame, as the user resize the application window.
    The mainwindow is a QWidget, with some other widgets placed using Designer.
    When I reduce the application frame, the right side is masked.
    How can I link the button so they can move with the right side (and eventually disapears to the left side if there isnt enough room ...)
    Thanks for your advices


  • Moderators

    @Furkas

    1. use QLayouts. Spacer <-> Widget
    2. call setGeometry()/move() manually in the resizeEvent() handler of the parent widget with the calculated position


  • Hi! To add to @raven-worx, have a look at this screenshot:

    screenshot layout

    First your central widget needs a horizontal layout. This can be selected in the property editor on the right. Next is to add a vertical layout from the component menu on the left (not shown in the screenshot). You can then drop your buttons in this vertical layout and also add one or more vertical spacers to it if you like.


Log in to reply
 

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