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. Qt47::Drag&Drop events using eventFilter
Forum Updated to NodeBB v4.3 + New Features

Qt47::Drag&Drop events using eventFilter

Scheduled Pinned Locked Moved General and Desktop
17 Posts 3 Posters 7.7k 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
    silex92
    wrote on last edited by
    #8

    How to receive any drag related event before the mimeData is called?

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

      One solution is to create your own custom listView and override some of the methods like

      @void dragEnterEvent(QDragEnterEvent *event);
      void dragMoveEvent(QDragMoveEvent *event);
      void dropEvent(QDropEvent *event);
      void startDrag(Qt::DropActions supportedActions);
      void mousePressEvent(QMouseEvent *event);
      void mouseMoveEvent(QMouseEvent *event);@

      You can also check the following examples

      1. "Draggable Icons Example":http://qt-project.org/doc/qt-4.8/draganddrop-draggableicons.html
      2. "Drag and Drop Puzzle Example":http://qt-project.org/doc/qt-4.8/draganddrop-puzzle.html
      1 Reply Last reply
      0
      • S Offline
        S Offline
        silex92
        wrote on last edited by
        #10

        dragEnterEvent is the default action for the QEvent::DragEnter in the QListView type if I am not mistaken.
        Probably the startDrag should be the right choice. The "QAbstractItemView documentation":http://harmattan-dev.nokia.com/docs/library/html/qt4/qabstractitemview.html?tab=3&q=QListView#startDrag
        does not provide such information.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #11

          [quote author="Sam" date="1379412553"]One solution is to create your own custom listView and override some of the methods like

          @void dragEnterEvent(QDragEnterEvent *event);
          void dragMoveEvent(QDragMoveEvent *event);
          void dropEvent(QDropEvent *event);
          void startDrag(Qt::DropActions supportedActions);
          void mousePressEvent(QMouseEvent *event);
          void mouseMoveEvent(QMouseEvent *event);@
          [/quote]

          Better override QAbstractItemView::viewportEvent() or it will result in the initial problem.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            silex92
            wrote on last edited by
            #12

            Could you explain why (in details)?
            [quote author="raven-worx" date="1379413191"][quote author="Sam" date="1379412553"]One solution is to create your own custom listView and override some of the methods like

            @void dragEnterEvent(QDragEnterEvent *event);
            void dragMoveEvent(QDragMoveEvent *event);
            void dropEvent(QDropEvent *event);
            void startDrag(Qt::DropActions supportedActions);
            void mousePressEvent(QMouseEvent *event);
            void mouseMoveEvent(QMouseEvent *event);@
            [/quote]

            Better override QAbstractItemView::viewportEvent() or it will result in the initial problem.

            [/quote]

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #13

              [quote author="silex92" date="1379413278"]Could you explain why (in details)?
              [/quote]
              When you look into the Qt source code you will see that viewportEvent() is actually the same like we already came up in the posts before (eventfilter on the viewport). When subclassing use this method instead of an eventfilter.

              [quote author="silex92" date="1379413166"]dragEnterEvent is the default action for the QEvent::DragEnter in the QListView type if I am not mistaken.
              Probably the startDrag should be the right choice. The "QAbstractItemView documentation":http://harmattan-dev.nokia.com/docs/library/html/qt4/qabstractitemview.html?tab=3&q=QListView#startDrag
              does not provide such information.[/quote]

              What exactly do you want to achieve actually?

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • S Offline
                S Offline
                silex92
                wrote on last edited by
                #14

                There's a QListView and additional view - QStackedWidget which provides the actual information for each QListView object.
                Hence, the pages(QStackedWidget) should be synchronized manually.
                When the pages' information is input by an user, the model is not updated. Hence, before the mimeData method is invoked the model should be updated.
                [quote author="raven-worx" date="1379413166"]
                What exactly do you want to achieve actually?
                [/quote]

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #15

                  so you just need to update the model as soon as something changes in your "pages" right?

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    silex92
                    wrote on last edited by
                    #16

                    The model should be updated only if an event is dragged.
                    [quote author="raven-worx" date="1379414696"]so you just need to update the model as soon as something changes in your "pages" right?[/quote]

                    1 Reply Last reply
                    0
                    • raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #17

                      [quote author="silex92" date="1379414823"]The model should be updated only if an event is dragged.
                      [/quote]

                      Then listen for the drag-enter event.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      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