[Closed] QListView: How to move QDrag::pixmap along Y-axis keeping x as constant (Drag and Drop)

  • I am working on a listView and have overridden the following functions:

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

    In the startDrag() function I have written:

    @void MyListView::startDrag(Qt::DropActions supportedActions)
    QByteArray itemData;
    QDataStream dataStream(&itemData, QIODevice::WriteOnly);

    ListWidgetItem *item = static_cast<ListWidgetItem *>(childAt(dragPoint));
    dataStream << dragPoint;
    QMimeData *mimeData = new QMimeData;
    mimeData->setData("application/x-QListView-DragAndDrop", itemData);
    drag = new QDrag(this);
    qDebug() << drag;
    QModelIndex indx = indexAt(dragPoint);
    if (drag->exec&#40;Qt::MoveAction | Qt::CopyAction&#41; == Qt::MoveAction&#41;


    Here I have used drag->setHotSpot() which places the QDrag::pixmap() at a particulat position while dragging.
    I am trying to change the HotSpot position in dragMoveEvent() but it does not change.

    How can I allow the QDrag::pixmap() to move only along the y-axis keeping x as constant ?



    Thanks for the concerns, I hope to get an update on either of the cases :)

  • Please don't ask the "same question":http://qt-project.org/forums/viewthread/20627/ twice.

    I have asked the other moderators to look into this one. They may or may not re-open this topic.

Log in to reply

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