Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. models

    Log in to post
    • All categories
    • F

      Unsolved How do deal with external changes to a model
      General and Desktop • views models columns qt 5 qt widget • • Folling

      4
      0
      Votes
      4
      Posts
      250
      Views

      F

      An update on this from my side:

      My initial approach wasn't flawless, as @VRonin pointed out, because QAbstractItemModel::columnCount didn't return the appropriate values. I've fixed this, by not immediately passing the new count after inserting the elements to a list, of which the size was used, but instead have the model save exactly how many categories it currently accounts for, so the connection looks like this:

      connect(item_registry.get(), &item_registry::category_added, [this](int position, QSharedPointer<category>) { beginInsertColumns(QModelIndex{}, position, position); _current_category_count++; endInsertColumns(); });

      and likewise columnCount:

      int item_model::columnCount(QModelIndex const&) const { if(!_register) { qCritical() << "Item-model didn't have a register"; return 0; } return 1 /* name */ + _current_category_count; }
    • I

      Unsolved ListView won't get updated when I change data in my custom model
      General and Desktop • models listview listmodel data models • • ivarec

      11
      0
      Votes
      11
      Posts
      1067
      Views

      Christian Ehrlicher

      Can we finally see where and how you emit dataChanged()? And with which indexes?

    • I

      Unsolved How to filter out columns in the new Quick Controls 2.12 TableView?
      QML and Qt Quick • tableview quick controls qml components models qsqltablemodel • • ivarec

      1
      0
      Votes
      1
      Posts
      296
      Views

      No one has replied

    • I

      Solved How to share database connection parameters between multiple QSqlTableModel objects?
      QML and Qt Quick • models model binding database qsqldatabase qsqltablemodel • • ivarec

      6
      0
      Votes
      6
      Posts
      926
      Views

      SGaist

      From the looks of it, you have to re-create the models when you change these settings.

    • C

      Unsolved Sorting with ignored items
      General and Desktop • sort models • • Craetor

      5
      0
      Votes
      5
      Posts
      857
      Views

      C

      @JonB, thanks, i will try your implementation.

    • corianderop

      Unsolved VXYModelMapper: how to define x and y values
      QML and Qt Quick • qml c++ charts models • • corianderop

      2
      0
      Votes
      2
      Posts
      1081
      Views

      S

      @corianderop Hi I am also stuck in a similar situation did you figure out a solution for it ?

    • K

      Unsolved What class of Proxy Model should I pick in the case?
      General and Desktop • qsortfilterprox models sort mapping filter • • Kofr

      4
      0
      Votes
      4
      Posts
      1304
      Views

      raven-worx

      @Kofr
      mapFromSource() and mapToSource() are enough. The default implementation should depend on these methods only.

    • Guy Gizmo

      Solved Can't get QColumnView to display more than one row of data with my QAbstractItemModel-derived class
      General and Desktop • qcolumnview qabstractitemmo models qtreeview • • Guy Gizmo

      2
      0
      Votes
      2
      Posts
      796
      Views

      Guy Gizmo

      Someone on stackoverflow was kind enough to point out my error. My parent method() should have been:

      QModelIndex MyModel::parent(const QModelIndex &index) const { if (!index.isValid()) { return QModelIndex(); } QObject *item = (QObject *)index.internalPointer(); Directory *parentItem = qobject_cast<Directory *>(item->parent()); if (!parentItem || parentItem == invisibleTopLevelDirectory()) { return QModelIndex(); } Directory *parentOfParentItem = qobject_cast<Directory *>(parentItem->parent()); if (!parentOfParentItem) { return QModelIndex(); } int listIndex = parentOfParentItem->indexOfItem(parentItem); if (listIndex < 0) { return QModelIndex(); } else { return createIndex(listIndex, index.column(), parentItem); } }
    • C

      Unsolved returning objects from roles
      QML and Qt Quick • qt-quick qml models roles • • clarity

      10
      0
      Votes
      10
      Posts
      2476
      Views

      ekkescorner

      @jpnurmi cool :)
      did some first tests with QAbstractListModel filled with some Customer* (QObject)
      inserted customers, removed customers, changed properties via C++
      all correct refreshed in QML ListView

      seems I can "port" most of my data model logic / UI from BlackBerry Cascades to Qt 5.6 :)

    • MrBolton

      Unsolved QIdenitityProxyModel with more rows than source model
      General and Desktop • models • • MrBolton

      1
      0
      Votes
      1
      Posts
      484
      Views

      No one has replied

    • E

      [Solved] Not all properties from ListModel are being made available to delegate
      QML and Qt Quick • qml models listmodel listview • • eLim

      5
      0
      Votes
      5
      Posts
      6123
      Views

      E

      I've managed to solve the problem by first adding a second property to the Components, so now the Component has this at the top:

      Component { id: frameworkHeaderElement Rectangle { property var modelData: [] property var propData: [] ... } ... }

      Then when the Component is Loaded during the Loader I've changed the onLoaded function to the following:

      onLoaded: { item.modelData = model item.propData = storiesModel.get(index) }

      Now I can access my index using modelData, and I can access all of my properties (which may be unique to a Component) through propData as follows

      text: propData.headerText

      I'm sure there's a better way to solve this, but for the time being this works just fine for what I need.

      Thanks for your help!