Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8482807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:54:38+00:00 2026-06-10T19:54:38+00:00

I have a QAbstractListModel based class defined in QT and in QML I have

  • 0

I have a QAbstractListModel based class defined in QT and in QML I have set this model to a GridView. It works perfect. If I change data in the model I call the reset function and GridView shows the updated data. But at time I change the complete model data (i.e Not just the data changes but also its count changes). In this case when I reset the data the GridView does not show the updated model. I have also tried to create a new object of my model and changed the GridView model but still no effect.

Here are the basic code snippet.

// DataEngine.h
class DataEngine : public QAbstractListModel
{
    Q_OBJECT
public:
    .....
public: // Overrides
    int rowCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
}
// main.c
DataEngine *data = new DataEngine();
view.rootContext()->setContextProperty("DataModel", data)

// QML File
GridView {
.....
id: view
model: DataModel
.....
}

// After completely changing data (i.e earlier it has 256 rows, now it has say 0 row)
// I tried
view.rootContext()->setContextProperty("NewDataModel", data)
// QML Code
view.model = NewDataModel     // No effect.

It seems to me the data is changing but GridView is not updating with the new data.

Any help is appreciated.

Best Regards,
Farrukh Arshad

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:54:39+00:00Added an answer on June 10, 2026 at 7:54 pm

    I suspect you’re failing to notify the underlying base model that your data has changed. See this section of the QAbstractItemModel for details on what you need to do in your child class. In particular, the following sentence says quite a bit:

    When implementing these functions, it is important to notify any connected views about changes to the model’s dimensions both before and after they occur:

    If you are removing reducing the data then you have to provide implementation of removeRows and if you are increasing data then you have to provide the implementation of insertRows. In my case since I had data from my own sources, I just deleted that data and was returning rowIndex as 0 that didn’t worked. I have just added an empty implementation of removeRows with beginRemoveRows & endRemoveRows inside return true, and emitted this signal. With this signal my view knows the data count is changed so it has called rowCount function where I have returned 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
Greetings all, I have extended my own QAbstractListModel to change the background color of
Have a look at this HTML code: <div class=overlay> <a href=#>1</a> <a href=#>1</a> <a
I have a virtual table view implementation with the following model: class MyModel: public
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have implemented a list of users in my Qt program, using the model/view
Have converted devise new session from erb to Haml but doens't work, this is
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.