Results 1 to 5 of 5

Thread: TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar)

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar)

    Hello,

    I'm using a QTreeView to show data. Everything is fine. Excepted for one thing. Instead of showing a showing a horizontal scrollbar if the treeview is resized the text is shortened and shows "..." at the end (see the last four item in the example).

    Example:

    (The horizontal scrollbar is shown, because i used setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn );, but it is useless as seen on the screenshot)

    I'm using the default delegate with a custom model. How can I get a working scrollbar instead of "..."
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar

    Hi,

    use
    Qt Code:
    1. QTreeView *treeView;
    2. treeView->setTextElideMode(Qt::ElideNone);
    To copy to clipboard, switch view to plain text mode 

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

    nightghost (15th October 2009)

  4. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar

    Ah nice. The "..." are gone. But the horizontal scrollbar is still unusable.

    Attached Images Attached Images

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar

    then you also have to use:
    Qt Code:
    1. view->header()->setResizeMode(0, QHeaderView::ResizeToContents);
    2. view->header()->setStretchLastSection(false);
    To copy to clipboard, switch view to plain text mode 
    It only might look "ugly" if you show the header because not the whole width is covered by the header.

  6. #5
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar

    Ah great it working. Thanks.

    A hint: Its only working if the methods are called AFTER the model is inserted into the QTreeView. Otherwise the colunm will be resized only one time.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.