Important: Please read the Qt Code of Conduct -

[Solved]ComboBox drag and drop issue

  • I have a requirement in which I have to drag an item from comboBox and drop it on a PushButton.

    For this I am writing a class for comboBox and handling all the drag events in the same class, also I am writing a class for pushButton where I am handling the drop event.

    The issue I am facing is that, when I am trying to drag the item from the comboBox, I can see the item moving, but on the same time none of the events are being called. And when I am dragging the whole comboBox the events are being called.

    If any one have some idea please do let me know.

    Thanks in Advance.

  • For your pushButton in the DragEnterEvent() check for the accpeted mimeData formats eg

    @qDebug() << event->mimeData()->formats();@

    and you get the result as


    Code :

    @void customButton::dragEnterEvent(QDragEnterEvent *event)
    qDebug() << event->mimeData()->formats(); //just for test

    This is a workaround you need to handle some filters/checks as per your requirement.

  • Thanks Sam for the reply.

Log in to reply