Results 1 to 5 of 5

Thread: Automatically scroll to current Index in QTreeView

  1. #1
    Join Date
    Nov 2012
    Posts
    23
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Automatically scroll to current Index in QTreeView

    I want to scroll automatically to currentIndex in verticalscrollbar of QTreeView which is populated by QFileSystemModel.
    I am trying it with QPropertyAnimation on the verticalScrollBar->setValue().
    I have a default index in the QTreeView which I set in a function, and so I want to scroll to it.

    void MainWindow::updateTree()
    {
    QString dir=QFileInfo(ui->lineEdit->text()).path();
    QModelIndex idx = model->index(dir);
    if (idx.isValid())
    {
    ui->treeView->setCurrentIndex(model->index(dir));
    ui->treeView->expand(idx);
    }
    }

    I am not good with QPropertyAnimation so please help me with this.

  2. #2
    Join Date
    Oct 2011
    Posts
    27
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Automatically scroll to current Index in QTreeView

    ???? "QTreeView::scrollTo" is not enough ???

  3. #3
    Join Date
    Nov 2012
    Posts
    23
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Re: Automatically scroll to current Index in QTreeView

    I already tried it but nothings happening

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Automatically scroll to current Index in QTreeView

    So why didn't you ask, "Why isn't QTreeView::scrollTo() scrolling to display the specified index when use like this? <insert your code>"?

    Two obvious options:
    • It is making sure the specified index is visible but you are expecting something else like automagically keeping the current index in view.
    • The index you have given it is not valid.

  5. #5
    Join Date
    Nov 2012
    Posts
    23
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Re: Automatically scroll to current Index in QTreeView

    I am just trying to scroll down until the currentIndex is visible, I read it somewhere I need to do it with QPropertyAnimation, if u people have any better solution then plesae tell, I would be glad. Just to say I want to scroll automatically to this folder Screenshot from 2013-03-01 12:54:36.png

Similar Threads

  1. QListView current row index?
    By noborder in forum Newbie
    Replies: 1
    Last Post: 3rd February 2013, 18:21
  2. How to get current focus index in QML ???
    By duc_bkav in forum Qt Programming
    Replies: 0
    Last Post: 25th November 2011, 04:28
  3. Replies: 3
    Last Post: 11th August 2010, 13:47
  4. Connect button and pass QListView current index
    By been_1990 in forum Qt Programming
    Replies: 3
    Last Post: 30th November 2009, 16:20
  5. How to get current row(column) index in the QTextTable?
    By denny.t in forum Qt Programming
    Replies: 3
    Last Post: 5th April 2006, 07:53

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.