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. [SOLVED] QAbstractListModel with custom data type
Forum Update on Monday, May 27th 2025

[SOLVED] QAbstractListModel with custom data type

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.9k 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.
  • P Offline
    P Offline
    panosk
    wrote on 26 Jan 2013, 17:30 last edited by
    #1

    Hello,

    I have created a QAbstractListModel that stores and displays a custom data type, Language objects whose constructors accept 2 QStrings and 1 QIcon. As a read-only model it works fine. However, I can't figure how to add new items to an empty model. In particular, I want to put items into an empty model from a populated one. This should be achieved with drag and drop and probably a button. Note that I don't want the items themselves to be editable.

    After searching for hours, I was able to find examples, both in the Docs and on the net, but all involved Qt's standard types (QStrings, etc), so I have trouble understanding how I should handle my custom data type and which functions I should reimplement.

    Any ideas or, better yet, any examples will be appreciated.

    Thanks

    1 Reply Last reply
    0
    • P Offline
      P Offline
      panosk
      wrote on 27 Jan 2013, 20:14 last edited by
      #2

      After searching in the wrong direction and messed up with mimeData, dropMimeData, etc, the solution was to implement correctly setData() and insertRows() and set the correct flags for drag and drop.

      1 Reply Last reply
      0

      1/2

      26 Jan 2013, 17:30

      • Login

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