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. QStandardItem custom drag MIME
QtWS25 Last Chance

QStandardItem custom drag MIME

Scheduled Pinned Locked Moved Solved General and Desktop
qstandarditemmime
4 Posts 3 Posters 724 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.
  • J Offline
    J Offline
    Joel Bodenmann
    wrote on 23 May 2020, 16:27 last edited by
    #1

    I'm desperately trying to figure out how I can set custom data MIME type and data on a QStandardItem. I would have expected that QStandardItem provides something similar to QStandardItem::setMimeData() which would allow to set the mime data (and type) for each individual item. However, that doesn't appear to be the case.

    What is the expected way of achieving this? I usually write my own models inheriting from QAbstractItemModel but the code I'm working on at the moment uses QStandardItemModel. Do I have to subclass it and re-implement QStandardItemModel::mimeData() ?

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    S 1 Reply Last reply 23 May 2020, 17:06
    0
    • J Joel Bodenmann
      23 May 2020, 16:27

      I'm desperately trying to figure out how I can set custom data MIME type and data on a QStandardItem. I would have expected that QStandardItem provides something similar to QStandardItem::setMimeData() which would allow to set the mime data (and type) for each individual item. However, that doesn't appear to be the case.

      What is the expected way of achieving this? I usually write my own models inheriting from QAbstractItemModel but the code I'm working on at the moment uses QStandardItemModel. Do I have to subclass it and re-implement QStandardItemModel::mimeData() ?

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 May 2020, 17:06 last edited by
      #2

      Hi,

      AFAIR, yes that's the way to do it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Joel Bodenmann
        wrote on 24 May 2020, 14:14 last edited by
        #3

        Got it working that way (no surprise there).

        However, I'd like to understand why QStandardItem does not offer a setMimeData() function. Looking at the existing design of QStandardItemModel and QStandardItem it seems feasible to implement this. Is this simply not implemented because nobody ever did it or is there a technical reason for this?

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 24 May 2020, 14:51 last edited by
          #4

          @Joel-Bodenmann said in QStandardItem custom drag MIME:

          However, I'd like to understand why QStandardItem does not offer a setMimeData() function.

          Because noone wants to create a mime data just on suspicion for every item.

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

          1 Reply Last reply
          0

          3/4

          24 May 2020, 14:14

          • Login

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