Results 1 to 8 of 8

Thread: Horizontal scroll bar on QTreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Horizontal scroll bar on QTreeView

    How is your view set up? Does it have stretchLastColumn property set to true? What are the resize policies of the columns?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Nov 2009
    Posts
    44
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Horizontal scroll bar on QTreeView

    Thank you so much for your quick response - it is appreciated. I'm using the Qt designer for this dialog, and all the items are set to the default except that I turned off word wrap and set the horizontal scroll bar to 'Always On'. I see a stretchHeaderLastSection, and that's checked. But I don't have a header, do I need one? The size policy for the QTreeView is Preferred, Expanding. I don't see a stretchLastColumn property or resize policies for individual columns - I must be looking in the wrong place, where do I find those? I set the resizeColumnToContents(0), but it doesn't seem to make a difference. Thanks again for your help.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Horizontal scroll bar on QTreeView

    Quote Originally Posted by LynneV View Post
    I see a stretchHeaderLastSection, and that's checked.
    Switch it off.
    But I don't have a header, do I need one?
    With a tree view you always have a header, it might not be visible though.
    I don't see a stretchLastColumn property or resize policies for individual columns - I must be looking in the wrong place, where do I find those?
    In the docs of QHeaderView

    I set the resizeColumnToContents(0)
    Bad idea.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following user says thank you to wysota for this useful post:

    LynneV (9th November 2010)

  5. #4
    Join Date
    Nov 2009
    Posts
    44
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Horizontal scroll bar on QTreeView

    The solution ended up to be: QStandardItemModel->SetHorizontalHeaderLabels( QStringList) AND QTreeView->setColumnWidth( 0, line_width ). Ether alone would not work..but together they do the trick! Why is resizeColumntoContents not a good idea? Just curious.

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Horizontal scroll bar on QTreeView

    Quote Originally Posted by LynneV View Post
    Why is resizeColumntoContents not a good idea?
    Because you are probably calling it before the sizes are calculated so it's likely a no-op.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    LynneV (10th November 2010)

Similar Threads

  1. Replies: 0
    Last Post: 5th July 2010, 09:05
  2. Resizing QTableView to eliminate horizontal scroll bar?
    By russford in forum Qt Programming
    Replies: 7
    Last Post: 18th March 2010, 07:21
  3. Vertical scroll bar, but resizable horizontal content
    By minimoog in forum Qt Programming
    Replies: 0
    Last Post: 14th January 2009, 20:51
  4. ListWidget horizontal scroll.
    By patrick772goh in forum Qt Tools
    Replies: 3
    Last Post: 17th July 2007, 07:32
  5. Replies: 1
    Last Post: 18th March 2006, 10:18

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.