开发者

How to move QSplitter?

Say I have a window, where there are 2 horizontal sppliters, and a button. How to move a splitter up/down by clicking o开发者_Python百科n the button?


Take a look at http://doc.qt.io/qt-4.8/qsplitter.html#setSizes. The main point is that there is no method to move the splitter explicitly, you can only achieve similar behaviour by resizing the widgets in the QSplitter themselves, which is easily accomplished by using QSplitter::setSizes. I would do something like

QList<int> currentSizes = mySplitter->sizes();
// adjust sizes individually here, e.g.
currentSizes[0]++;
currentSizes[1]--;
mySplitter->setSizes(currentSizes);

which would move a horizontal splitter with two widgets by one pixel. You would have to add a check to avoid negative sizes, of course.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜