PDA

View Full Version : layouts, sizePolicy, sizeHint,



Kronen
5th November 2009, 05:34
http://s4.subirimagenes.com/otros/3508586sash.jpg

I'm learning Qt and trying to code a multiplayer card game and I have some doubts managing the geometry of widgets.
In the image above there are the scene, the QListWidget with the players, and a QTextBrowser for the chat and I want the QListWidget not to take its sizeHint, so the QTextbrowser expands to the left, how could I do that?.


QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(listWidget);
layout->addWidget(textBrowser);

QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(view);
layout2->addLayout(layout);

QWidget *window = new QWidget;
window->setLayout(layout2);

Thanks, and sorry my bad english.

axeljaeger
5th November 2009, 07:59
You dont want the listview to ignore the size hint. The size hint is way smaller than what you get on the screen.

The problem is that both widgets, the text browser and the listview have their sizePolicy in x-dimension set to "preferred". Set the sizePolicy of the textbrowser to Expanding in the x-direction and you are fine.

Kronen
5th November 2009, 18:43
What I meant is that I want the width of the listWidget to be less than the actual sizeHint(maybe little more than the broadest player name), I thougth that I could do that expanding the textBrowser's width like you said, but I get the same that I had before with:


textBrowser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

And of course I get the listWidget's width to be the sizeHint() adding:


listWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);

http://s4.subirimagenes.com/otros/3511237sash.jpg

Sorry for my stupidity.