Results 1 to 3 of 3

Thread: QListView: How to move the cursor to a specific row

  1. #1
    Join Date
    Jul 2008
    Posts
    47
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QListView: How to move the cursor to a specific row

    Hello,

    I have a QListView with >100 entries.

    I have the issue, that I can move the selection with code, but not the cursor.

    Let's make an example:

    1) I click on the first entry in the list.
    2) The entry get's selected
    3) At a later time, I use QItemSelectionModel->select( ...row 50 ... , QItemSelectionModel::ClearAndSelect )
    4) I also use QListView->scrollTo ( ... row 50 ..., QAbstractItemView::PositionAtCenter )

    Now the row 50 is selected and is in the middle of the QListView.

    So far so good and as expected.

    But if I then press the cursor key down, the QListView jumps to row 2 instead of row 51.

    So the selection I can define, but not where the cursor is.

    In QListView I can find method for moving to first, last, next, ... but not something moveTo (row = 50).

    Do you have any hint for me, where to look for getting the cursor also moved to row 50?
    Anyway, I don't need a cursor different to the selection in any case.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListView: How to move the cursor to a specific row

    have you tried calling QAbstractItemView::setCurrentIndex()?

  3. #3
    Join Date
    Jul 2008
    Posts
    47
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: QListView: How to move the cursor to a specific row

    Thanks,

    that's exactly what I was searching for.

Similar Threads

  1. how to move item up and down in QListView
    By zhanglr in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2008, 14:39
  2. Replies: 0
    Last Post: 10th November 2006, 13:46
  3. how to move cursor to specific line in Text
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2006, 09:55

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.