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. If you could change the Drag'n'Drop API in QAbstractItemModel, what would you do?
Qt 6.11 is out! See what's new in the release blog

If you could change the Drag'n'Drop API in QAbstractItemModel, what would you do?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 42 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.
  • V Offline
    V Offline
    Volker Hilsheimer
    wrote last edited by
    #1

    Hi all,

    I'm looking into implementing drag'n'drop defaults and customization points in QRangeModel. In the spirit of QRangeModel, the logic to "do stuff with data" should be close to the data type, rather than land in a subclass of QRangeModel.

    Drag'n'drop in QAIM manifests itself in 4 virtual functions:

    • QStringList mimeTypes() returns a list of mime types that the model can "work with" in both directions
    • QMimeDate *mimeData(const QModelIndexList &indexes) const encodes the data at indexes into one, some, or all of the mimeTypes - that's up to the model
    • bool canDropMimeData(data, action, row, column, parent) and dropMimeData(..) then handle the drop into a specific location, the interpretation of which is documented convention rather than an enforced rule

    In addition there are relevant flags in Qt::ItemFlags, and then of course the interaction with the views, which is not relevant for this work (or at least out of scope for now).

    If you have overridden those APIs for your own models, what did you find difficult, what did you find most limiting, and what stood out as straight forward and easy to do?

    Customization of QRangeModel is done by specialising the QRangeModel::RowOptions and/or QRangeModel::ItemAccess templates for your own row- and item- types. So we have some flexibility to come up with a better set of APIs, as long as we can map the 4 virtual functions to whatever we end up with.

    Drop a comment here or at https://qt-project.atlassian.net/browse/QTBUG-145800

    Cheers,
    Volker

    1 Reply Last reply
    1

    • Login

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