Widgets inside another widget should resize



  • HI,

    I have one widget and added to QVBoxLayout
    and one more widget set has parent .

    m_widget = new QWidget;
        m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    
        m_anotherwidget = new CConfigurePTZ(m_widget);
        m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    

    when i expand window m_widget is expanding, but the m_anotherwidget is not expanding.

    How to achieve this .

    Thanks,



  • Hi @Pradeep-Kumar

    Try to add a layout to your m_widget, i think that this is the problem.



  • Hi,

    i tried adding QHBoxLayout to m_widget, still not expanding

    m_HBoxLayout = new QHBoxLayout;
    m_HBoxLayout->addWidget(m_Widget);
    

    still m_anotherwidget is not expanding.



  • @Pradeep-Kumar
    close, but you have to define m_anotherwidget as part of your m_HBoxLayout.
    Otherwise you have just 2 unrelated widgets lying ontop of each other.


  • Lifetime Qt Champion

    You have to set your layout on a widget for it to do something.



  • as @SGaist said

    you have to add

    m_widget->setLayout(m_HBoxLayout);



  • ```
    

    m_widget = new QWidget;
    m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    m_anotherwidget = new CConfigurePTZ(m_widget);
    m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    

    m_HBoxLayout = new QHBoxLayout;
    m_HBoxLayout->addWidget(m_Widget);

    i have a gridlayout and my hboxlayout setting it to vboxlayout.

    m_pQVBoxLayout->addLayout(m_GridLayout);
    m_pQVBoxLayout->addLayout(m_HBoxLayout);
    this->setLayout(m_VBoxLayout);

    
    how can i modify hboxlayout?.
    
    Thanks,


  • can anyone suggest how this can be achieved?.


  • Moderators

    @Pradeep-Kumar said in Widgets inside another widget should resize:

    how can i modify hboxlayout?

    What do you want to modify in hboxlayout?
    You should really read about layouts in Qt.



  • You are confusing which widget should go in the layout and which widget the layout applies to

    m_widget = new QWidget;
    m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    
    m_anotherwidget = new CConfigurePTZ(m_widget);
    //m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    
    QHBoxLayout* widgetLay = new QHBoxLayout(m_widget);
    widgetLay->addWidget(m_anotherwidget);
    
    m_VBoxLayout->addWidget(m_widget);
    this->setLayout(m_VBoxLayout);
    


  • Hi,

    Thanks guys.


Log in to reply
 

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