Important: Please read the Qt Code of Conduct -

Hiding the control in a layout and filling it with the other control

  • I have to custom widgets which are displayed side by side in a QHBoxLayout as shown in the picture.


    In the Widget2 there is a signal attached to a slot which constantly monitors for a variable. if the variable is null then widget2 should not be displayed and widget1 should stretch to the entire area of the layout. as shown in the picture below.


    What I have written for the state when the two widgets are displayed

    widget1 = new Widget1(this);
    widget2 = new Widget2(this);
    QHboxLayout* hLayout = new QHboxLayout();
    hLayout->addwidget( widget1,5);

    How I can hide this and achieve the state 2 based on the subscribed variable change output?

  • @thomasjohnaj


    You mixed the names in your image and in your description text. "Widget1 should stretch", but image label says "widget2" :)
    But doesnt matter... it's the same for every widget :)

Log in to reply