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. Bug(?) with modal dialog and drag&dop

Bug(?) with modal dialog and drag&dop

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 463 Views
  • 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.
  • T Offline
    T Offline
    tgoetz
    wrote on last edited by
    #1

    Hi Qt hive,

    I have a user interface with dialogs. In one of the dialogs I am using QListWidgets to present QListWidgetItems that the user can drag&drop from one list to other receiver list.

    The source code of my dialog looks like this:

    [...]
    DragDialog::DragDialog(QWidget* parent) : QDialog(parent)
    {
      setWindowTitle("Drag&Drop Test");
      QListWidget* source = new QListWidget();
      source->setAlternatingRowColors(true);
      source->setSelectionMode(QAbstractItemView::SingleSelection);
      source->setDragEnabled(true);
      source->setDragDropMode(QAbstractItemView::DragDrop);
      source->setDefaultDropAction(Qt::MoveAction);
      source->viewport()->setAcceptDrops(true);
      source->setDropIndicatorShown(true);
    
      // names is a QStringList with the names of US presidents just to fill the list
      for(auto const name : names)
      {
        auto item = new QListWidgetItem(name);
        item->setToolTip(name);
        item->setData(Qt::UserRole, name);
        source->addItem(item);
      }
    
      QListWidget* target1 = new QListWidget();
      target1->setAlternatingRowColors(true);
      target1->setSelectionMode(QAbstractItemView::SingleSelection);
      target1->setDragEnabled(true);
      target1->setDragDropMode(QAbstractItemView::DragDrop);
      target1->setDefaultDropAction(Qt::MoveAction);
      target1->viewport()->setAcceptDrops(true);
      target1->setDropIndicatorShown(true);
    
      QHBoxLayout* layout = new QHBoxLayout();
      layout->addWidget(source);
      layout->addWidget(target);
    
      setLayout(layout);
    }
    [...]
    

    And here is the relevant part of the corresponding main.cpp :

    int main(int argc, char* argv)
    {
      QApplication app(argc, argv);
    
      DragDialog dialog;
      dialog.show();
    
      app.connect(&app, &QApplication::lastWindowClosed, &app, &QApplication::quit);
    
      return app.exec();  
    }
    

    When I am using show() - as in the main.cpp above - to display the dialog, everything works fine and I can drag items from one list to the other and back. However, if I use exec(), the dialog freezes when I start to move a single item and I have to log in from a different machine to kill the process.

    Has anybody seen this before and a way out?

    I am using a system installation of Qt 5.9.2 on CentOS 7.5 (1804). On a different system, we have been using 5.6 and 5.9.3 and it was no problem.

    Thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tgoetz
      wrote on last edited by
      #2

      I was able to reduce the code to this snippet that still generates the error on my system:

      #include <QtWidgets/QApplication>
      #include <QtWidgets/QDialog>
      #include <QtWidgets/QListWidgetItem>
      #include <QtWidgets/QListWidget>
      #include <QtWidgets/QVBoxLayout>
      
      
      int main (int argc, char **argv)
      {
        QApplication app(argc, argv);
      
        QDialog dialog;
      
        QListWidget* source = new QListWidget();
        source->setDragEnabled(true);
      
        new QListWidgetItem("foo", source);
      
        new QVBoxLayout(&dialog);
        dialog.layout()->addWidget (source);
      
        return dialog.exec();
      }
      
      1 Reply Last reply
      0
      • T Offline
        T Offline
        tgoetz
        wrote on last edited by
        #3

        This is an actual bug in 5.9.2, see https://bugreports.qt.io/browse/QTBUG-63968

        1 Reply Last reply
        4

        • Login

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