QGraphicsSceneDragDropEvent::source() documentation error



  • 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
    }
    @


  • Lifetime Qt Champion

    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



  • 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?


Log in to reply
 

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