How to get a signal each time an item is dragged in a QListWidget.

  • I have a custom QListWidget for my GUI based application, I want to have a signal each time I drag an item inside the QListWidget. I read somewhere about using the signal something like new row added of model of the QListWidget but I am not so clear about it.

  • For your listWidget are you overriding the methods like startDrag() , dragMoveEvent(), dropEvent()

    If yes, then you can easily emit a signal when calling startDrag() function.


  • Yeah i have them, which signal should i emit?

  • You can create your own signal and then emit it when you are calling startDrag()


    void itemDrag();@


    @void yourListView::mouseMoveEvent(QMouseEvent *event)
    int distance = (event->pos()- dragPoint).manhattanLength();

    if (distance >= 4) // QApplication::startDragDistance()   

    emit itemDrag();

    you can also emit inside startDrag() function as per your convenience, then connect the signal of your list to the slot where you want to handle the implementation.

  • Thank u so much
    Now its working

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.