Results 1 to 16 of 16

Thread: QListView drag and drop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView drag and drop

    No, you should be returning the logical AND of whatever flags there already are (QStringListModel:: flags()) with the bitwise NOT of Qt:: ItemIsDropEnabled. My original post had a logical OR, and I realized the mistake and fixed it a bit later.

    Qt Code:
    1. return QStringListModel::flags( index ) & ~Qt::ItemIsDropEnabled;
    To copy to clipboard, switch view to plain text mode 

    Your code doesn't compile because you left out the "index" argument to the superclass call. In this case, I also left out the argument, but seriously, you have to look at what the compiler is telling you and figure out what is wrong.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Jan 2020
    Posts
    53
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QListView drag and drop

    Quote Originally Posted by d_stranz View Post
    No, you should be returning the logical AND of whatever flags there already are (QStringListModel:: flags()) with the bitwise NOT of Qt:: ItemIsDropEnabled.
    Qt Code:
    1. return QStringListModel::flags( index ) & ~Qt::ItemIsDropEnabled;
    To copy to clipboard, switch view to plain text mode 
    Yes, you are right. However, this prevents all drop actions in the view. The solution to the problem, which can be found here, is to AND in Qt::ItemIsDropEnabled only if (index.isValid()). So now the problem is fixed.

Similar Threads

  1. Need help regarding drag and drop in QListView.
    By sonulohani in forum Qt Programming
    Replies: 6
    Last Post: 8th May 2016, 09:13
  2. qt 3.3 qlistview drag and drop
    By harishiva in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2011, 12:46
  3. Replies: 2
    Last Post: 13th October 2010, 21:51
  4. Drag and Drop from QListView to QGraphicsView
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 20th August 2009, 14:26
  5. Problem with drag&drop in qlistview
    By mambo in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 16:14

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.