Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. models
    Log in to post

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

      4
      0
      Votes
      4
      Posts
      86
      Views

      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; }
    • UNSOLVED ListView won't get updated when I change data in my custom model
      General and Desktop • listview listmodel data models models • • ivarec  

      11
      0
      Votes
      11
      Posts
      633
      Views

      Can we finally see where and how you emit dataChanged()? And with which indexes?
    • UNSOLVED How to filter out columns in the new Quick Controls 2.12 TableView?
      QML and Qt Quick • tableview qsqltablemodel quick controls models qml components • • ivarec  

      1
      0
      Votes
      1
      Posts
      158
      Views

      No one has replied

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

      6
      0
      Votes
      6
      Posts
      573
      Views

      From the looks of it, you have to re-create the models when you change these settings.
    • UNSOLVED Sorting with ignored items
      General and Desktop • models sort • • Craetor  

      5
      0
      Votes
      5
      Posts
      496
      Views

      @JonB, thanks, i will try your implementation.
    • UNSOLVED VXYModelMapper: how to define x and y values
      QML and Qt Quick • qml c++ charts models • • corianderop  

      2
      0
      Votes
      2
      Posts
      870
      Views

      @corianderop Hi I am also stuck in a similar situation did you figure out a solution for it ?
    • UNSOLVED What class of Proxy Model should I pick in the case?
      General and Desktop • qsortfilterprox models sort filter mapping • • Kofr  

      4
      0
      Votes
      4
      Posts
      1001
      Views

      @Kofr mapFromSource() and mapToSource() are enough. The default implementation should depend on these methods only.
    • SOLVED Can't get QColumnView to display more than one row of data with my QAbstractItemModel-derived class
      General and Desktop • qtreeview qabstractitemmo models qcolumnview • • Guy Gizmo  

      2
      0
      Votes
      2
      Posts
      678
      Views

      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); } }
    • UNSOLVED returning objects from roles
      QML and Qt Quick • qml models qt-quick roles • • clarity  

      10
      0
      Votes
      10
      Posts
      2134
      Views

      @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 :)
    • UNSOLVED QIdenitityProxyModel with more rows than source model
      General and Desktop • models • • MrBolton  

      1
      0
      Votes
      1
      Posts
      377
      Views

      No one has replied

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

      5
      0
      Votes
      5
      Posts
      5289
      Views

      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!