Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Hang observed at drag->exec() when a qwidget is dragged after a QMessageBox error message has popped up.
Qt 6.11 is out! See what's new in the release blog

Hang observed at drag->exec() when a qwidget is dragged after a QMessageBox error message has popped up.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 2.0k Views 1 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.
  • S Offline
    S Offline
    Sriu1
    wrote on last edited by Sriu1
    #1

    Hi I'm working on an application for dragging and dropping of qwidgets.The drag and drop is working fine.I also have some QMessageBox poping up when position of qwidget dropped in improper locations.When I drop the widget in an improper location I get proper error messages in the form of QMessageBoxes,but after getting the pop ups If I drag the qwidget I'm observing a hang at drag->exec().Below is my code for dragging
    void Base::mouseMoveEvent (QMouseEvent *event)
    {
    if (event->buttons() & Qt::LeftButton)
    {
    {
    if (item)
    {
    QMimeData *mimeData = new QMimeData;
    mimeData->setText ("X");
    quintptr address = (quintptr)item;
    QByteArray b (QString::number (address).toLatin1());
    mimeData->setData (QStringLiteral ("image/x-puzzle-piece"), b);
    QDrag *drag = new QDrag (this);
    drag->setMimeData (mimeData);
    //Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
    drag->exec();
    //setCursor(Qt::OpenHandCursor);
    //drag->setPixmap(QPixmap(":/images/person.png"));
    //if (drag->exec (Qt::MoveAction) == Qt::MoveAction)
    //{ /delete item;/ }

        update();
    }
        }
    }
    
    QWidget::mouseMoveEvent (event);
    

    }

    This is my code for showing popups if the widget is dropped in improper location
    QMessageBox msg;
    msg.critical (0, "Error", errorMessage);
    msg.show();

    When I try to drag widget after the error message has come and "ok" is clicked It hangs at drag->exec().Please suggest

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

      Hi,

      Why not just disallow dropping on improper location ?

      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
      • S Offline
        S Offline
        Sriu1
        wrote on last edited by Sriu1
        #3

        @SGaist
        Hi,
        Thanks for the reply.

        I have different conditions for Improper Location's.Basically the Improper locations are dynamic(depend on the locations of other QWidgets).The application has to clearly tell the user why the QWidget shouldn't be dropped in that location.So I tell the user through QMessageBox error popups.I couldn't find any alternative for QMessageBox.Please suggest If any.My issue is similar to this post and this .The drag->exec() is not getting returned.
        I'm working on Linux platform.

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

          How do you currently define that it's not allowed to drop ?

          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
          • S Offline
            S Offline
            Sriu1
            wrote on last edited by
            #5

            Hi @SGaist

            void Base::dropEvent (QDropEvent *event)
            {
            Base *source =
            qobject_cast<Base *> (event->source());

            if (source && source != this)
            {
               drop...
            }
            

            }

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

              See the dropping part of the Drag And Drop chapter of Qt's documentation. You should simply refuse the action in dragEnterEvent.

              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
              1

              • Login

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