Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Qt.io webservices
  4. QGraphicsSceneDragDropEvent::source() documentation error
Forum Updated to NodeBB v4.3 + New Features

QGraphicsSceneDragDropEvent::source() documentation error

Scheduled Pinned Locked Moved Qt.io webservices
3 Posts 2 Posters 1.3k 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.
  • D Offline
    D Offline
    deleted587
    wrote on last edited by
    #1

    The documentation for QGraphicsSceneDragDropEvent::source() states "This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent". However, this function actually returns the source of the QDropEvent that the QGraphicsView processed while creating the QGraphicsSceneDragDropEvent. Also, it may be helpful to mention that QGraphicsSceneDragDropEvent::widget() returns a pointer to the QGraphicsView's viewport. At least I didn't find that behavior to be obvious.

    I almost forgot to mention, I would have placed a note on the QGraphicsSceneDragDropEvent page, but I don't seem to have permission.

    The relevant code (for 5.3.1)

    @
    void QGraphicsView::dropEvent(QDropEvent *event)
    {
    #ifndef QT_NO_DRAGANDDROP
    Q_D(QGraphicsView);
    if (!d->scene || !d->sceneInteractionAllowed)
    return;

    // Generate a scene event.
    QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDrop);
    d->populateSceneDragDropEvent(&sceneEvent, event);
    
    // Send it to the scene.
    QApplication::sendEvent(d->scene, &sceneEvent);
    
    // Accept the originating event if the scene accepted the scene event.
    event->setAccepted(sceneEvent.isAccepted());
    if (sceneEvent.isAccepted())
        event->setDropAction(sceneEvent.dropAction());
    
    delete d->lastDragDropEvent;
    d->lastDragDropEvent = 0;
    

    #else
    Q_UNUSED(event)
    #endif
    }
    @
    and
    @
    void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
    QDropEvent *source)
    {
    #ifndef QT_NO_DRAGANDDROP
    Q_Q(QGraphicsView);
    dest->setScenePos(q->mapToScene(source->pos()));
    dest->setScreenPos(q->mapToGlobal(source->pos()));
    dest->setButtons(source->mouseButtons());
    dest->setModifiers(source->keyboardModifiers());
    dest->setPossibleActions(source->possibleActions());
    dest->setProposedAction(source->proposedAction());
    dest->setDropAction(source->dropAction());
    dest->setMimeData(source->mimeData());
    dest->setWidget(viewport);
    dest->setSource(qobject_cast<QWidget *>(source->source()));
    #else
    Q_UNUSED(dest)
    Q_UNUSED(source)
    #endif
    }
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can open a documentation bug report on the "bug report system":http://bugreports.qt-project.org and if you wish contribute a patch to make the needed corrections

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted587
        wrote on last edited by
        #3

        Thank you for the reply. I've created bug report QTBUG-40800. Until the bug can be addressed, can someone please create a doc note on the page?

        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