Important: Please read the Qt Code of Conduct -

How to raise a separate widget in a main window?

  • Hi,

    I'm creating an application with many different widgets, let say that the widgets are distributed in 8x8 matrix in a QGridLayout.

    Since the widgets are very small, I want to click on a widget at location e.g 4x4 (matrix sense), and then this widget is raised in full size and shown on top of the main window....Pretty much as an advanced pop-up window. When I want to lower the widget again, I just click lower, or close the widget and then it re-apperas in the main window again with the new modified settings.

    How can I do this?

    Best regards,

    Ole J. Hagen

  • Qt Champions 2017

    I feel you should work mouseEvents and resizing of window/widget. This is very much like any soft-keyboard.

  • Hi,

    Ok, a new description.
    A Qt application with a QMainWindow consists of 16 tiny widgets arranged in a 4x4 matrix. All of these widgets contains two sliders, a knob and a progressbar.

    When I want to change something in a widget located at location (3,3), then the widget is too small to be used. Therefore I want to raise the selected widget from the MainWindow and be in front of the MainWindow and resize it so we can change the parameters in it. When we are finished changing parameters, then the widget should go back to it's original location at (3,3).

    How can this be done?
    I guess I need to do re-parenting to 0 for the particular widget that I choose, and re-parent it back to MainWindow when I'm finished with it.

    How can I be certain that this widget ends up at the location (3,3) again?

    How can I solve this?


  • Qt Champions 2017

    Would you mind sharing your email id ? I can send you the sample program which does this similar stuff. Based on this you can design your screen.

  • QWidget::raise() for displaying in front of any other sibbling widget, and QWidget::stackUnder(QWidget * w) to restore its position in the children stack, of course preserving before the bigger resizing the widget under which it should be stacked (the widget upward in the stack)

    hope it helps :)

Log in to reply