Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drag-drop with internalmove makes items disappear

Drag-drop with internalmove makes items disappear

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalas
    wrote on last edited by
    #1

    Hi,

    I'm trying to make drag and drop inside a treewidget work to be able to move items around. I've managed to make items draggable but when I release the mouse button the item disappears. I've tried the following example from stackoverflow and this has the same issues as my tree widget in Qt 5.4 on Windows 7.

    #include <QListWidget>
    
    int main(int argc, char **argv)
    {
        QApplication a(argc, argv);
    
        QListWidget lw;
    
        for(int i = 1; i < 10; ++i)
            lw.addItem(new QListWidgetItem(QString("Item %1").arg(i)));
        lw.setDragEnabled(true); // ***
        lw.viewport()->setAcceptDrops(true); // ***
        lw.setDefaultDropAction(Qt::MoveAction); // ***
        lw.setDropIndicatorShown(true); // ***
    
        lw.setDragDropMode(QAbstractItemView::InternalMove);
    
        lw.show();
    
        a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
        a.exec();
    }
    

    Here's how this looks for me:
    Imgur

    Any ideas?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you try again with Qt 5.5 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        tried the code with 5.5 and it does work there.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved