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. [SOLVED] QQuickWidget doesn't accept drops
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QQuickWidget doesn't accept drops

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 2.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.
  • F Offline
    F Offline
    frankiefrank
    wrote on last edited by
    #1

    I'm using a subclass of QQuickWidget and want to make use of drop acceptance functionality that is supposed to work considering it's a QWidget class (and because the docs don't mention anything about it not working).

    Some code:
    @

    // QuickWidget.h

    #include <QQuickWidget>

    class QuickWidget : public QQuickWidget
    {
    Q_OBJECT

    public:
    QuickWidget(QWidget *parent = 0);
    virtual void dragEnterEvent(QDragEnterEvent *event);
    };
    @

    @

    // QuickWidget.cpp

    // ...

    void QuickWidget::dragEnterEvent(QDragEnterEvent *event)
    {
    if (true)
    {
    // Some code with a breakpoint
    }
    }
    @

    MainWindow code:
    @

        qw = new QuickWidget(this);  // qw is a member of type QuickWidget * defined in the main window header
    

    setCentralWidget(qw);
    qw->setAcceptDrops(true);

    @

    Now trying to drag some selected text into the window - nothing happens (the breakpoint doesn't hit).

    Alternatively, replaced the QuickWidget with a Widget (QWidget subclass with the same override of the drag enter code) - drag enter code hits breakpoint as expected.

    Am I correct in saying that setAcceptDrops doesn't work properly for QQuickWidget?

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      The drop happens in the QML scene (add a DropArea in the qml to handle it) so my guess is you would have to pass that to the C++ side manually somehow (don't know QML that well). I don't think QQuickWidget handles this kind of propagation automatically.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        agocs
        wrote on last edited by
        #3

        Drag and drop works fine with QQuickWidget but, as pointed out above, you are supposed to handle it via a DropArea in the Qt Quick scene. Reimplementing dragXxxEvent or dropEvent is futile since QQuickWidget never invokes these.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Strange. It is not up to QQuickWidget to "invoke" the event handlers. It should be the other way around: QQuickWidget should be reimplementing the handlers itself in order to handle the events in QML. Appearently, it is not doing that, but probably is reimplementing the generic event handler instead, thereby IMHO breaking the contract of providing the virtual functions in the first place.

          You should be able to check the above by reimplenting the event method, and checking if the d&d related events do pass through there.

          Please file a bug for it.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            frankiefrank
            wrote on last edited by
            #5

            Thank you for your replies.

            Andre - you were right - reimplementing QuickWidget::event() I managed to intercept the drag enter event. This is really what I wanted so I'm changing this to SOLVED and will open a bug as suggested.

            By the way, since the recent spam comments in the forums, I find that I sometimes don't get e-mail notifications for legit comments on my posts. So only seeing this now. Sorry and thank you once again!

            "Roads? Where we're going, we don't need roads."

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              When you filed your bug, please cross-reference the bugreport and this topic by putting a link to this topic in the bugreport, and then a link to your bugreport in this topic.

              1 Reply Last reply
              0
              • F Offline
                F Offline
                frankiefrank
                wrote on last edited by
                #7

                Opened bug:
                https://bugreports.qt.io/browse/QTBUG-43821

                "Roads? Where we're going, we don't need roads."

                1 Reply Last reply
                0
                • R resist referenced this topic on

                • Login

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