PDA

View Full Version : Setting cell width in QHBoxLayout



EricF
13th December 2007, 13:28
Hi, is there a way to set a column width in QHBoxLayout. I've been trying to play with the size policy of elements in the cell but even setting them to fixed, the cell still grow.

Is there a kind of stretch factor that means no stretch ?

What I'm trying to do is a kind of watch window like in Visual Studio where you have the variable name and a field beside to edit it. And since I want these line to be dragable, I thought of using multiple QHBoxLayout inside a QVBoxLayout. But the label on the left obviously won't align.

I would have used a QGridLayout however, it does not support insert(for drag and drop).

Would I be better served using a tricked TreeView or TableView ?

high_flyer
13th December 2007, 14:13
I've been trying to play with the size policy of elements in the cell but even setting them to fixed, the cell still grow.

Are you sure you are doing it correctly?
For me it works fine.

EricF
13th December 2007, 14:26
My problem is when I resize the window, how does the layout distribute the new space ? I was also testing with labels.

high_flyer
13th December 2007, 14:47
My problem is when I resize the window, how does the layout distribute the new space ?
just as I would expect - the fixed size object stays the same, the other ones expand, see images.

EricF
13th December 2007, 15:08
Well I must have been tired. I made it work. However, would you do it with nested layout like this or you would prefer a QTableWidget for example ?

high_flyer
13th December 2007, 15:42
I would have used a QGridLayout however, it does not support insert(for drag and drop).

If indeed the QGridLayout does not support drag and drop (I didn't check this), but the nested layouts do, and you need that feature, then use the nested layouts.