开发者

resize qwidget in a layout manually on runtime

I have a QVBoxLayout with a few widgets in it (QTableViews). Now these QTableViews all have the same size. What can I do, that the user can change the size of one QTableView on runtime (so that 1 QTableView is bigg开发者_运维知识库er than the other one)? Maybe with a "seperator" which you can change with the mouse?


Use a QSplitter: http://doc.qt.digia.com/4.6/qsplitter.html

If you have this code:

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(table1);
layout->addWidget(table2);
layout->addWidget(table3);
setLayout(layout);

You should be able to just change it to:

QSplitter *splitter = new QSplitter;
splitter->addWidget(table1);
splitter->addWidget(table2);
splitter->addWidget(table3);
splitter->setOrientation(Qt::Vertical);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(splitter);
setLayout(layout);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜