@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.