QTreeView drag/drop "icon" Transparency
-
Hey
When we drag treeItems in QTreeView when drag begins there is a picture of dragged items used as a "helper" of what is being dragged. I would like to change the transparency of that helper so I can easier see what's behind it.
How can I do it?
Or... how can I recapture the picture myself if I have to rebuild drag event myself ?This is what I see now > - the orange "box" is the dragged item snap.
Regards
Dariusz -
Currently not possible: https://bugreports.qt.io/browse/QTBUG-57173
-
@Christian-Ehrlicher said in QTreeView drag/drop "icon" Transparency:
Currently not possible: https://bugreports.qt.io/browse/QTBUG-57173
Welp off I go rewriting Qt logic I suppose then... thanks for info!
-
@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() -
@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.