Skip to content
  • 0 Votes
    5 Posts
    949 Views
    D

    @raven-worx said in QTreeView drag/drop "icon" Transparency:

    @Dariusz
    the only way currenlty is to start the drag entirely yourself by overwriting QAbstractItemView::startDrag()
    Its not that hard. Simply get the data for all selected indexes from the model and set a custom drag pixmap and call QDrag::exec()

    Hey

    Id love to do it but sadly it does not work. For example >

    def startDrag(self, supportedActions): d = QDrag(self) data = self.model().mimeData(self.selectedIndexes()) d.setMimeData(data) d.exec_(supportedActions)

    It Will, not produce the same effect as native action. Simply because when you look at source code where >

    if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction) d->clearOrRemove();

    Which handles the items state after their drag.
    I can not reproduce the action without a large rewrite of the startDrag event I'm afraid.

    I wish that the function that they use for Pixmap generation >

    QPixmap pixmap = d->renderToPixmap(indexes, &rect); rect.adjust(horizontalOffset(), verticalOffset(), 0, 0); QDrag *drag = new QDrag(this); drag->setPixmap(pixmap);

    Would be a virtual function so that I can overwrite it and provide my own pixmap at that level without messing up entire drag Qt logic.

  • 1 Votes
    3 Posts
    2k Views
    M

    @jpnurmi Thanks for the clarification!

  • 0 Votes
    5 Posts
    3k Views
    SGaistS

    That's not how it works and not something I would expect either.

    The mdi sub-windows will only extend in the mdi area, nothing more.

    The behavior you are looking for, you'll have to implement yourself.

  • 0 Votes
    2 Posts
    2k Views
    mrjjM

    Hi and welcome

    Maybe
    void QDrag::setPixmap(const QPixmap & pixmap)
    Could be used ?
    You set it when you start the drag so it sounds it might do what you want.