0

I'm using Qt 5.8. I have my custom QFrame (call it MyQFrame), which consists of several other QWidgets and can (and will) contain other instance of my custom MyQFrame. I set minimum size for MyQFrame. MyQFrame uses QGridLayout as layout.

This MyQFrame is placed inside of QScrollArea in QTabWidget. QScrollArea is set to be resizable (setWidgetResizable(true)). In MyQFrame I tried to set size policy to expanding (setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);) but it was without effect.

This is (abstraction) how I create QTabWidget and QScrollArea:

QTabWidget* tabWidget = new QTabWidget();
QScrollArea* firstTab = new QScrollArea();
firstTab->setWidgetResizable(true);
tabWidget->addTab(firstTab, "first tab");
MyQFrame* myFrame1 = new MyQFrame();
firstTab->setWidget(myFrame1);
// ... adding other MyQFrames inside this one using methods in MyQFrame ...

I cannot get scroll area working. Instead of expanding parents of nested MyQFrames and adding scroll bar is last child getting overlaped by other MyQFrames. Looks like I'm missing something like setWidgetResizable for MyQFrames, but this method is only in QScrollArea. I have no idea what should I try now. I'm still pretty new to this.

It should be more clear from image below.

overlaping

4

1 回答 1

0

正如我所说,我在 MyQFrame 中使用 QGridLayout。我必须将此布局的大小约束设置为最小大小,如下所示layout->setSizeConstraint(QLayout::SetMinimumSize);:现在它正在按我想要的方式工作。

于 2017-03-19T23:31:47.413 回答