PDA

View Full Version : QGridlaout - Dynamic deployment in a grid



h-n-s
22nd March 2013, 11:34
Hi,
I have a problem with placing a widget in a grid.
I want the widgets they added to the grid without a position.

GridLayout->addWidget(myWidget)
But when trying to add Wiget is a program that adds it in a vertical position (one by one).
I want wigety were added horizontally.

Temporarily, I fixed it this way ... I put it in the net three wigety horizontal position (qt designer), then when you create the window destructor and destroying doing these three wigety. I can now add to the grid dynamically wigety the way I wanted.
This is not an elegant solution.

Please help and sorry for my English.

Santosh Reddy
22nd March 2013, 14:39
If you don't want to mention the position, then you have two options
1. Write your own Layout, and other
or
2. Use QHBoxLayouts on QVBoxLayouts, and put the QWidgets on QHBoxLayout

h-n-s
22nd March 2013, 20:05
It's not working.
Must be manually placed at least two widgets that made ​​the grid. Otherwise, the widgets are added in a single line ;/

Santosh Reddy
25th March 2013, 07:10
Give us a sample compiling program of how you are doing things.

h-n-s
25th March 2013, 20:40
Code for U.

Santosh Reddy
26th March 2013, 14:29
Ok, here is code back with changes which I think you wanted to behave like.

Note that I changed the some layout setting to make the UI fit on to my small 15" laptop screen, please ignore then if you needed a fixed size window, it's up to you.