Results 1 to 7 of 7

Thread: QTreeView Horizontal Scrollbar issue

  1. #1
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default QTreeView Horizontal Scrollbar issue

    I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot:

    Qt Code:
    1. connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
    2. connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
    To copy to clipboard, switch view to plain text mode 

    The slot consists of one line of code:

    Qt Code:
    1. void update_scroll_area(const QModelIndex& i)
    2. {
    3. resizeColumnToContents(i.column());
    4. }
    To copy to clipboard, switch view to plain text mode 

    This makes scrollbar working, but only when I'm expanding/collapsing the tree view items.

    I need to have working horizontal scrollbar "every time", from starting the application till its end. How can it be organized?

    Thank you.

    UPD: Have tried this code, but didn't help:
    Qt Code:
    1. header()->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    2. header()->setResizeMode(QHeaderView::ResizeToContents);
    3. header()->setStretchLastSection(false);
    To copy to clipboard, switch view to plain text mode 
    Last edited by Dehumanizer; 13th July 2011 at 12:35.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTreeView Horizontal Scrollbar issue

    Scroll bars appear as and when needed by default. This is default behaviour, you don't need to set anything.
    I need to have working horizontal scrollbar "every time", from starting the application till its end. How can it be organized?
    Do you mean that, scroll bar should be visible even when table widget fits the veiw port? (I mean even when not needed)

  3. #3
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QTreeView Horizontal Scrollbar issue

    I understand the 'appearance' of the scroll-bar. I don't need scrollbar to appear when it doesn't need, but when tree's content's length is larger than 'holder area', the scrollbar doesn't appear, even if I set ScrollbarAlwaysOn.

    At the end of the row appears "...", instead of showing scrollbar to allow me to scroll to row's real end.
    (Hope, have described my problem correctly). Can you give some advice?

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTreeView Horizontal Scrollbar issue

    look like the column's header's text's width is considered to show/hide horizontal scroll bar, if the column's header's text's width is less than the columns's text's width the ... is appears.

    I am also working on finding a solution for this, I am creating a sub-class of QTreeView and altering some veiwport size options. I am still exploring this, will post updates on this soon.

  5. #5
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QTreeView Horizontal Scrollbar issue

    Ok, thanks for reply. Waiting for updates

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTreeView Horizontal Scrollbar issue

    this should fix your problem
    Qt Code:
    1. header()->setStretchLastSection(true);
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QTreeView Horizontal Scrollbar issue

    Have tried, doesn't fix. Have you other suggestions?

Similar Threads

  1. Resize a vertical an horizontal scrollbar.
    By IRON_MAN in forum Qt Programming
    Replies: 3
    Last Post: 19th April 2010, 15:45
  2. QCompleter with horizontal ScrollBar
    By vajindarladdad in forum Newbie
    Replies: 2
    Last Post: 31st August 2009, 06:01
  3. How to add a horizontal scrollbar to a treeview?
    By yangyunzhao in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2009, 08:24
  4. QTreeWidget horizontal scrollbar
    By ttvo in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2009, 16:44
  5. Horizontal scrollbar problem
    By blaylockr in forum Newbie
    Replies: 2
    Last Post: 21st July 2008, 17:38

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.