I use QGridLayout
very often, and there's a requirement I don't know how to or if I can achieve with this kind of layouts.
My question: Imagine I have two normal widgets (derived from QWidget
) on the left and right (on something like QHBoxLayout
or QGridLayout
), and I would like to have the line separating them movable by the user. Is that possible?
More information: To give an example, imagine the default Windows registry editor. You have the part on the left, where there are keys and paths, and on the right, where there are values to be edited.
I would like to emphasize that I'm not asking for an explorer view. What I have basically is a plot widget on the right, and a QTableView
widget on the left, and I would like the user to be able to conveniently scale with his mouse, which widget should be horizontally bigger.
Is there some kind of Layout that is scalable by mouse?
Please ask for more information of you require it.
I think you should use a QSplitter.
According to the documentation:
For example, using Qt Creator, if we have two
QGridLayout
with aQPushButton
on each one, we can select bothQGridLayout
and use theLay Out Horizontally in Splitter
option.After that, we could move the boundary between them to control the size of child widgets:
I made an example. Here you have the code for the ui file: