How to using mouse to change size of grid layout cells using Qt?

帅比萌擦擦* 提交于 2019-12-07 10:15:57

问题


I use grid layout (horizontal and vertical too). I like the fact that when resizing the window fills the entire window contents. but this extension is poorly managed. I often want to change the size of only one column in grid layout without changing the size of the window. such as in Windows Explorer. there are two columns - the left list of directories and their contents to the left to the right. and i can always press mouse button therebetween and pulling change the mutual sizes of columns in relation to each other.

how can I do this in Qt?


回答1:


You need to use a QSplitter rather than a QGridLayout in this specific case (where you just want 2 widgets shown together). QSplitters are draggable.




回答2:


You are looking for QSplitter

(The following is the procedure in the Qt Designer)

  1. Group your widgets, and click Lay Out Horizontally/Vertically in Splitter

  1. Put this group into another layout (QGridLayout, for example) to automatically expand it.
  2. Congrats! Your Layout is now draggable(from step1) and expandable(from step2).


来源:https://stackoverflow.com/questions/26671001/how-to-using-mouse-to-change-size-of-grid-layout-cells-using-qt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!