Results 1 to 5 of 5

Thread: Navigate through qlistview items with shortcuts

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Navigate through qlistview items with shortcuts

    This forum doesn't work like "Hey, I need a function, could you guys code it for me?" so let's put it this way: what did you try so far?
    J-P Nurmi

  2. #2
    Join Date
    Aug 2007
    Posts
    244
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    42
    Thanked 8 Times in 8 Posts

    Default Re: Navigate through qlistview items with shortcuts

    Quote Originally Posted by jpn View Post
    This forum doesn't work like "Hey, I need a function, could you guys code it for me?" so let's put it this way: what did you try so far?
    I'm sorry if I give this impression, but the problem is that I haven't found in the documentation an hypothetically QListViewItemIterator (as in qt3); there is a QListIterator but it not seems usable in my case. My listview is using as model a QSqlTableModel but i have not found in its documentation an iterator or so.

    Searching in the forum I have found this discussion, but QItemSelectionModel has
    Qt Code:
    1. select( const QModelIndex &, QItemSelectionModel::SelectionFlags )
    To copy to clipboard, switch view to plain text mode 
    which should work but i don't know how retrieve next/previous QModelIndex of the selected item.

    Regards
    Giuseppe CalÃ

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Navigate through qlistview items with shortcuts

    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    jiveaxe (10th January 2008)

  5. #4
    Join Date
    Aug 2007
    Posts
    244
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    42
    Thanked 8 Times in 8 Posts

    Default Re: Navigate through qlistview items with shortcuts

    Thanks jpn, sibling was what I need (I'm italian so sometimes i don't understand the use of a function from its name: I had no idea of what was simling; after you pointed me to it I have recovered a thesaurus to get the meaning of that word and discovered that it was the function I was searching for).

    Now the final code:

    Qt Code:
    1. void MainDialog::showPreviuosTitle()
    2. {
    3. QModelIndex mi = listView->currentIndex();
    4. if(mi.row() > 0) {
    5. listView->setCurrentIndex(mi.sibling(mi.row()-1,mi.column()));
    6. viewTitle(listView->currentIndex());
    7. }
    8. }
    9.  
    10. void MainDialog::showNextTitle()
    11. {
    12. QModelIndex mi = listView->currentIndex();
    13. if(mi.row() < listView->model()->rowCount() - 1) {
    14. listView->setCurrentIndex(mi.sibling(mi.row()+1,mi.column()));
    15. viewTitle(listView->currentIndex());
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    Thanks
    Giuseppe CalÃ

Similar Threads

  1. Items in QListView should sort on Header Click
    By vinnu in forum Qt Programming
    Replies: 14
    Last Post: 10th November 2006, 12:49
  2. moving Qlistview items
    By :db:sStrong in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2006, 12:25

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.