Results 1 to 3 of 3

Thread: layouts, sizePolicy, sizeHint,

  1. #1
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question layouts, sizePolicy, sizeHint,

    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?.

    Qt Code:
    1. QHBoxLayout *layout = new QHBoxLayout;
    2. layout->addWidget(listWidget);
    3. layout->addWidget(textBrowser);
    4.  
    5. QVBoxLayout *layout2 = new QVBoxLayout;
    6. layout2->addWidget(view);
    7. layout2->addLayout(layout);
    8.  
    9. QWidget *window = new QWidget;
    10. window->setLayout(layout2);
    To copy to clipboard, switch view to plain text mode 

    Thanks, and sorry my bad english.

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: layouts, sizePolicy, sizeHint,

    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.
    It's nice to be important but it's more important to be nice.

  3. The following user says thank you to axeljaeger for this useful post:

    Kronen (5th November 2009)

  4. #3
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: layouts, sizePolicy, sizeHint,

    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:

    Qt Code:
    1. textBrowser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. listWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    To copy to clipboard, switch view to plain text mode 

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

    Sorry for my stupidity.

Similar Threads

  1. correct sizeHint of QItemDelegate
    By nifei in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2008, 10:50
  2. sizeHint based off visible text
    By joshuajcarson in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2008, 17:51
  3. QTableView sizeHint() issues
    By akos.maroy in forum Qt Programming
    Replies: 3
    Last Post: 20th September 2008, 23:42
  4. sizeHint()
    By sm in forum Newbie
    Replies: 11
    Last Post: 22nd January 2008, 04:59
  5. 2 Questions about layouts
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2006, 14:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.