Results 1 to 2 of 2

Thread: Qt::ItemIsDropEnabled ignored in dragDropMode QAbstractItemView::InternalMove

  1. #1
    Join Date
    Jul 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt::ItemIsDropEnabled ignored in dragDropMode QAbstractItemView::InternalMove

    i have a QTreeWidget that looks like this:

    dragDropMode is QAbstractItemView::InternalMove
    my problem is, that e.g. Row 2 can be dropped at Row 1 although Row 1 misses Qt::ItemIsDropEnabled:


    i just want the user to be able to move the items up/down by drag/drop but not to drop one item at another
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Qt::ItemIsDropEnabled ignored in dragDropMode QAbstractItemView::InternalMove

    Looks like it may be a bug in Qt Creator.

    From the QTreeWidgetItem::flags() docs:
    If the item was constructed with a parent, flags will in addition contain Qt::ItemIsDropEnabled.
    In the generated ui.h file the items are added with the treeWidget as parent and the items are definitely drop enabled, yet the property editor has DropEnabled unchecked.

    If you were adding the items in your code you could unset the flag before you add the item to the treeWidget. When you add the items within Qt Creator the only way that I see to unset the flag is to iterate through the items.

    Try adding something like the following to your treeWidget constructor:
    Qt Code:
    1. for(int i=0; i<ui->treeWidget->topLevelItemCount(); ++i)
    2. ui->treeWidget->topLevelItem(i)->setFlags(ui->treeWidget->topLevelItem(i)->flags() & ~Qt::ItemIsDropEnabled);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 26th November 2009, 18:28
  2. QAbstractItemView
    By zgulser in forum Qt Programming
    Replies: 3
    Last Post: 19th August 2009, 12:30
  3. Help on QListWidget InternalMove item signal
    By tho97 in forum Qt Programming
    Replies: 3
    Last Post: 14th February 2009, 01:13
  4. QAbstractItemView::InternalMove
    By youkai in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2008, 17:54
  5. QAbstractItemView
    By defumar in forum Newbie
    Replies: 9
    Last Post: 22nd January 2008, 13:50

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.