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. Question about overriding QAbstractItemModel::mimeData()
Forum Update on Monday, May 27th 2025

Question about overriding QAbstractItemModel::mimeData()

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 451 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by
    #1

    The argument to this function is const QModelIndexList &indexes, and the return value is a pointer to QMimeData.

    If there is more than one QModelIndex in the list, obviously I must somehow make a list or an array of the corresponding QMimeData data elements before returning from this function.

    So my question is this: What is the expected format of the object behind the QMimeData pointer? Is it an array, or a single object?

    If it is an array, do I have to delimit it with a "null" (or default initialized) QMimeData object?
    If it is a single object, I assume that I must somehow stream the data for ALL the QModelIndex's into a QByteArray (or perhaps a QJsonDocument and export that as a QByteArray)?

    What if I have a custom view and some columns hold text, while others might hold images? Does all of this data have to fit into a single object of type QMimeData assuming, e.g. that I select several rows of two columns each (with different types of data) and try to drag them to a different widget?

    The documentation could perhaps be a little more specific here.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It is whatever you need to pass your data around. The receiving class must be able to decode it.

      One interesting example for big data structure is the Qt 4.8 Drag And Drop delayed encoding example.

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

      R 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        It is whatever you need to pass your data around. The receiving class must be able to decode it.

        One interesting example for big data structure is the Qt 4.8 Drag And Drop delayed encoding example.

        R Offline
        R Offline
        Robert Hairgrove
        wrote on last edited by
        #3

        @sgaist : Thanks ... I realized just now that the documentation of this function becomes quite clear when one looks at the source code of QAbstractItemModel::mimeData() in the file "../qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp" at line 1936.

        It even says "Returns an object (...)" -- i.e., all one really needs to know.

        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