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
Forum Updated to NodeBB v4.3 + New Features

QStandardItem custom drag MIME

Scheduled Pinned Locked Moved Solved General and Desktop
qstandarditemmime
4 Posts 3 Posters 750 Views 2 Watching
  • 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.
  • Joel BodenmannJ Offline
    Joel BodenmannJ Offline
    Joel Bodenmann
    wrote on 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

    SGaistS 1 Reply Last reply
    0
    • Joel BodenmannJ Joel Bodenmann

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

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      • Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on 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
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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

          • Login

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