Results 1 to 2 of 2

Thread: QTreeWidget - setting an absolute height

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Question QTreeWidget - setting an absolute height

    Hi all,

    I've searched for this, but don't see anyone saying it can be done. I have seen people saying it can't. I just wanted to make sure that this is the case.

    In software that I am now beginning to support, I have created a new dockable panel in an existing dock area. I have a QVBoxLayout with two QTreeWidgets in it, each having a QLabel just before (so it's QLabel over QTreeWidget over QLabel over QTreeWidget). I want a known amount of rows in each of these, and chose QTreeWidget because it is easy to add items that have columns, and to add headers for those columns.

    The first tree widget has 3 rows in it, and the second has 6, but the QVBoxLayout is giving them the same amount of space each. I would like to have an absolute height, where each widget shows only the rows it has, with no whitespace below. I tried setting the stretch factor for the two labels and the first tree widget to 0, and then tried 1 for the second tree widget. I even tried up to 3 for the second, but all that does is to create greater height for the second tree widget and it doesn't reduce the height of the first.

    I also looked into styling the widget, but the Qt page describing styling doesn't show any ability for styling to limit widget height/width.

    I know that I can set the size policy to fixed for each, but I don't see how I can set the size hint for a tree widget. This is slightly frustrating. I'm not sure why it should be difficult to constrain tree widgets to the size I need them to be.

    Can anyone tell me where I am going wrong here? Is there something that I can do to get these tree widgets to be sized exactly to show their 3 and 6 rows respectively? If not, it must be possible to maybe choose another widget to get the effect I am looking for. Any ideas?

    Thanks...

  2. #2
    Join Date
    Oct 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QTreeWidget - setting an absolute height

    Ok, so there isn't a way to do this. I ended up creating a QWidget per QTreeWidget, putting a layout into each QWidget, and putting my QTreeWidgets into those layouts. Then, setting the geometry of the outer widgets worked spankingly.

Similar Threads

  1. Replies: 6
    Last Post: 29th April 2014, 04:04
  2. How to make a QTreeWidget readjust row height!
    By Berryblue031 in forum Qt Programming
    Replies: 4
    Last Post: 29th May 2013, 18:31
  3. Dymanic setting row height in a QTreeView
    By fruzzo in forum Qt Programming
    Replies: 0
    Last Post: 15th September 2011, 14:49
  4. Setting QGraphicsTextItem height?
    By Dutch112 in forum Qt Programming
    Replies: 3
    Last Post: 11th August 2009, 11:03
  5. setting row height in QTreeView?
    By gfunk in forum Qt Programming
    Replies: 3
    Last Post: 28th July 2006, 00:47

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.