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. [Closed] QListView: How to move QDrag::pixmap along Y-axis keeping x as constant (Drag and Drop)
Forum Updated to NodeBB v4.3 + New Features

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

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

    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;
    drag->setMimeData(mimeData);
    drag->setHotSpot(mapToParent(QPoint(item->x(),y)));
    drag->setPixmap(currentPixmap);
    
    QModelIndex indx = indexAt(dragPoint);
    
    if (drag->exec&#40;Qt::MoveAction | Qt::CopyAction&#41; == Qt::MoveAction&#41;
     {
        model(&#41;->removeRow(indx.row());
     }
    

    }@

    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

    Edit:

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

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

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

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

      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