Adjusting size between 2 widgets within a gridlayout (beginner question)
-
wrote on 24 Jun 2011, 13:46 last edited by
I have 2 widgets within a QGridLayout that are touching each other. Each of them take up half of the layout by default, but the user can't adjust the size between them. What I mean is, I'd like the user to be able to drag the separator between the two widgets and adjust the size, so that one size gets bigger and the other gets smaller. I've looked through the docs for a function that allows you to do this with no luck. Any ideas?
-
wrote on 24 Jun 2011, 13:57 last edited by
Try QSplitter instead of QGridLayout.
-
wrote on 24 Jun 2011, 14:09 last edited by
Hi odonnemr,
When i begin to use Qt, i also have this question before :D
The answer is:- QGridLayout will handle the position and the size of it's child widget(which in the layout). 2) Basiclly, the position can not be change, but we also have workaround solution. And for size, it can be change, you can have a look at the sizePolicy of the QWidget, but for your requirement, i think we'd better use the workaround.
a. Use QML to write UI, it's more convenient for UI
b. Write a container wrapper, which make your widget embeded, and set the container wrapper to the QGridLayout. And do adjust size as usual
- QGridLayout will handle the position and the size of it's child widget(which in the layout). 2) Basiclly, the position can not be change, but we also have workaround solution. And for size, it can be change, you can have a look at the sizePolicy of the QWidget, but for your requirement, i think we'd better use the workaround.
-
wrote on 24 Jun 2011, 14:31 last edited by
what kind of container would you recommend chuck?
-
wrote on 24 Jun 2011, 14:47 last edited by
QWidget based is ok. Set the container to the layout, and handle the size change inside the container.
-
wrote on 24 Jun 2011, 16:11 last edited by
Thanks for your help guys, QSplitter did the trick
3/6