Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

enter image description here

like image 723
MaxKu Avatar asked Oct 31 '14 09:10

MaxKu


2 Answers

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.

like image 148
jpo38 Avatar answered Nov 15 '22 07:11

jpo38


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

enter image description here

  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).
like image 42
Tay2510 Avatar answered Nov 15 '22 06:11

Tay2510