Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

problem when Adding button in Horizontal layout



  • my main Layout is vertical laout.
    I am adding 4 things on it:
    1.Widget
    2.button1
    3.scrollarea
    4.button 2.
    And first,I want to add widget and button 1 in to horizontal layout.and add that layout in vertical layout.so not senario is something like this:
    1.horizontal layout(Which contain widget and button1)
    2.scrollarea
    3.button2
    Now problem is that when I add widget or button1 in to horizontal layout,the program get crashed.

    Code:

       m_pVerticalTabWidget = new QWidget(this);
    
       m_pBucHeaderWidget = new QWidget();
       m_pVLayout = new QVBoxLayout();
        m_pVerticalTabWidget->setLayout(m_pVLayout);
    
       HLayout_TopButton=new QHBoxLayout();
     ButtonLabelAtTop= new QPushButton();
        ButtonLabelAtTop->setMaximumWidth(40);
        HLayout_TopButton->addWidget(ButtonLabelAtTop);
    
     m_pScrollArea = new QScrollArea;
         m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    
        ButtonLabelAtButtom= new QPushButton();
    
      m_pVLayout->addLayout(HLayout_TopButton);
       m_pVLayout->addWidget(m_pScrollArea);
       m_pVLayout->addWidget(ButtonLabelAtButtom);
    


  • @hjohn said in problem when Adding button in Horizontal layout:

    Now problem is that when I add widget or button1 in to horizontal layout,the program get crashed.

    So in the code as shown above, which line are you claiming actually "crashes"?


Log in to reply