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. QTreeView drag/drop "icon" Transparency
QtWS25 Last Chance

QTreeView drag/drop "icon" Transparency

Scheduled Pinned Locked Moved Solved General and Desktop
qtreeviewqdrag drag dropqdragindicator
5 Posts 3 Posters 1.2k Views
  • 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 13 Feb 2021, 16:36 last edited by Dariusz
    #1

    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.
    c477143f-56cd-4dfa-9353-1f0f3d6d9cc4-image.png
    Regards
    Dariusz

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 13 Feb 2021, 16:58 last edited by
      #2

      Currently not possible: https://bugreports.qt.io/browse/QTBUG-57173

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply 13 Feb 2021, 17:03
      3
      • C Christian Ehrlicher
        13 Feb 2021, 16:58

        Currently not possible: https://bugreports.qt.io/browse/QTBUG-57173

        D Offline
        D Offline
        Dariusz
        wrote on 13 Feb 2021, 17:03 last edited by
        #3

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

        R 1 Reply Last reply 13 Feb 2021, 19:34
        0
        • D Dariusz
          13 Feb 2021, 17:03

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

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 13 Feb 2021, 19:34 last edited by raven-worx
          #4

          @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()

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          D 1 Reply Last reply 16 Feb 2021, 00:17
          1
          • R raven-worx
            13 Feb 2021, 19:34

            @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()

            D Offline
            D Offline
            Dariusz
            wrote on 16 Feb 2021, 00:17 last edited by Dariusz
            #5

            @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 Reply Last reply
            0

            4/5

            13 Feb 2021, 19:34

            • Login

            • Login or register to search.
            4 out of 5
            • First post
              4/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved