Hallo, I have to manage 3 different layout for each tab of a QTabWidget (but, in general, for its currentWidget).
MyClass::MyFunction is called every time a layout change is necessary.
In fact, my code is not able to let m_pWidget1 and m_pWidget2 be resized (both have resize() function overwritten, but it's not called as I expect).
Why?
And: How can I force m_pWidget1 and m_pWidget2 to be resized?
I post the code (initializations omitted, but it's not there the problem):
// .h
class MyClass
{
};
// .h
class MyClass
{
QTabWidget * m_pTabWidget;
QHBoxLayout * m_pHLayout;
QWidget * m_pWidget1;
QWidget * m_pWidget2;
};
To copy to clipboard, switch view to plain text mode
// .cpp
void MyClass::MyFunction(void)
{
m_pHLayout->setMargin(0);
m_pHLayout->setSpacing(0);
switch(m_eLayout)
{
case e_Layout_1:
{
m_pHLayout->addWidget(m_pWidget1);
m_pHLayout->addWidget(m_pWidget2);
}
break;
case e_Layout_2:
{
m_pHLayout->addWidget(m_pWidget1, 1);
m_pHLayout->addWidget(m_pWidget2, 2);
}
break;
case e_Layout_3:
{
m_pHLayout->addWidget(m_pWidget1, 2);
m_pHLayout->addWidget(m_pWidget2, 1);
}
break;
}
m_pTabWidget->currentWidget()->setLayout(m_pHLayout); //HERE - I expect that the resize event for both m_pWidget1 and pWidget2 is called.....
}
// .cpp
void MyClass::MyFunction(void)
{
m_pHLayout = new QHBoxLayout();
m_pHLayout->setMargin(0);
m_pHLayout->setSpacing(0);
switch(m_eLayout)
{
case e_Layout_1:
{
m_pHLayout->addWidget(m_pWidget1);
m_pHLayout->addWidget(m_pWidget2);
}
break;
case e_Layout_2:
{
m_pHLayout->addWidget(m_pWidget1, 1);
m_pHLayout->addWidget(m_pWidget2, 2);
}
break;
case e_Layout_3:
{
m_pHLayout->addWidget(m_pWidget1, 2);
m_pHLayout->addWidget(m_pWidget2, 1);
}
break;
}
m_pTabWidget->currentWidget()->setLayout(m_pHLayout); //HERE - I expect that the resize event for both m_pWidget1 and pWidget2 is called.....
}
To copy to clipboard, switch view to plain text mode
Bookmarks