Results 1 to 4 of 4

Thread: how to move item up and down in QListView

  1. #1
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    1

    Question how to move item up and down in QListView

    Hi,

    In my test application, I have one QListView and two buttons -- Up and Down. When up is clicked I want the current select item in QListView is moved up (E.g. now I have strings 1, 2, 3, 4 in QListView. and I selected 3. after I clicked up. I want the order is 1,3,2,4 and after it, 3 must still be selected.).

    Actually, I have two questions about it:
    1. How can I move one item up/down?
    2. How can I display the selection item even QListView has losted the focus?

    Anybody know, what need I do?

    Best Regards,
    Michael zhang

  2. #2
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to move item up and down in QListView

    You will have implement removeRows() and insertRows() as well as setData() in your subclassed QAbstractItemModel - I think

  3. #3
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    1

    Default Re: how to move item up and down in QListView

    Hi Valheru,

    Looks like I have to do remove item, add item and select item again.

    BTW, Do you know how to do display the selection item even QListView has losted the focus?

    Anyway, thanks a lot for your reply.

    Best Regards,
    Michael zhang

  4. #4
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to move item up and down in QListView

    I'm not entirely sure what you mean by that, but I think what you want to take a look at is the QItemSelection class. You can buffer the currently selected items using that class, and then access them via your instance of QItemSelection.

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.