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. How to get a signal each time an item is dragged in a QListWidget.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
5 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
    sargeslash
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      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.

      Regards
      Soumitra.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sargeslash
        wrote on last edited by
        #3

        Yeah i have them, which signal should i emit?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sam
          wrote on last edited by
          #4

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

          Eg.
          .h

          @signals:
          void itemDrag();@

          .cpp

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

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

          {
          emit itemDrag();
          startDrag(Qt::MoveAction);
          }
          }@

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sargeslash
            wrote on last edited by
            #5

            Thank u so much
            Now its working

            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