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 4616032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:55:28+00:00 2026-05-22T01:55:28+00:00

I recently started rewriting an application and I’m trying to port it to model/view

  • 0

I recently started rewriting an application and I’m trying to port it to model/view to reduce the number of kludges I have there.

So far I was able to succcessfully make a read-only model inheriting from QAbstractTableModel. This model is something like this:

class MyModel(QtCore.QAbstractTableModel):
    def __init__(self, data, parent=None):
        super(MyModel, self).__init__(parent)
        self.data = data

data is a list that contains a number of objects. These are then accessed in the data() method:

   def data(self, index, role):

       # much stuff omitted for clarity
       return QtCore.QVariant(self.data[index.column()].id)

Now this is fine if I work with a predefined data element. But in fact data changes programmatically (it expands when certain signals are received). How can I keep the model aware of this, so that then my view can also react to these changes?

I’ve been reading about read-write models but they also allow the user to edit and change things, while in my view I want things to be un-editable: in short, the model would need to be changed “behind the scenes” only, and the view adapt to that.

What is the best appproach in this case? Implement a read-write model with setData() and so on, or is there a simpler solution?

  • 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-05-22T01:55:29+00:00Added an answer on May 22, 2026 at 1:55 am

    My logview application uses QAbstractTableModel with a dynamic list – of log records, which increases dynamically as records are received across the network. You can download the source code and take a look at LogRecordModel, which is a QAbstractTableModel subclass, as is PropertySheetModel. Both of these are read-only models.

    It’s a pretty simple application using Qt model/view APIs, so you should be able to adapt its techniques for your own application.

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

Sidebar

Related Questions

Have recently started working with Sitecore 6.2. Is there a way to preserve code
Recently started programming Android Java (Eclipse), Im trying to make a simple reader app
I recently started using android actionbars and contextual action bars (CAB). I have just
I recently started a project where I have to authenticate users against the Active
Recently started working with the scrapy library. I am trying to scrape from a
I recently started testing my application using a release build (Manage Schemes and set
I recently started learning perl and have a question that I'm not finding a
I recently started using git and have a question. I have two branches of
We recently started providing a data extract to clients via an XML. We have
I recently started using WPF and the MVVM framework, one thing that I have

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.