Results 1 to 7 of 7

Thread: QTreeView Horizontal Scrollbar issue

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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.