Results 1 to 3 of 3

Thread: How to reorder items in QListView?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to reorder items in QListView?

    You still want the root index to accepts drops, just not the items so try:
    Qt Code:
    1. Qt::ItemFlags MyListModel::flags(const QModelIndex&index) const
    2. {
    3. Qt::ItemFlags flags; //= QStringListModel::flags(index);
    4.  
    5. if (index.isValid())
    6. flags = Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled;
    7. else
    8. flags = Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
    9.  
    10. return flags;
    11. }
    To copy to clipboard, switch view to plain text mode 
    This will work if the root index is invalid (as it usually is). However, if you use setRootIndex you may have to compare against that index instead.

  2. The following user says thank you to numbat for this useful post:

    xfurrier (12th August 2009)

  3. #2
    Join Date
    Jan 2009
    Posts
    20
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to reorder items in QListView?

    exactly what I wanted. thanx.

Similar Threads

  1. Removing all items QListView
    By vcp in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2009, 18:55
  2. how to get item's text or path from QListVIew
    By Mystical Groovy in forum Qt Programming
    Replies: 4
    Last Post: 5th September 2008, 01:25
  3. reorder items in QListView/QTreeView
    By sreedhar in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2008, 12:50
  4. Items in QListView should sort on Header Click
    By vinnu in forum Qt Programming
    Replies: 14
    Last Post: 10th November 2006, 12:49
  5. 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.