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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:53:16+00:00 2026-05-20T20:53:16+00:00

I’m writing a Qt application to allow the visualization of very heavy data sets.

  • 0

I’m writing a Qt application to allow the visualization of very heavy data sets.

So, I have a SourceDataModel class, inheriting from QAbstractItemModel that seems to work properly (currently, I only display it in QTableView/QTreeView but later on, I’ll create some custom views).

Now, I would like to be able to filter this data, that is

  1. being able to have different data
    resolution (i.e. only exposing 1
    data item out of 2)

  2. being able to
    apply some filters on the data (i.e.
    displaying unix timestamps as
    dd/MM/yyyy hh:mm:ss)

So I started to create a ProxySourceDataModel class, which inherits from my SourceDataModel and stores one instance, and basically delegates everything to the instance. From this ProxySourceDataModel, I noticed that no data was displayed when I used it in a QTableView. After some investigation, it seems that it was because i had to forward the signals and slots from the underlying SourceDataModel. No problem, i did it.

But still 2 problems remain, and I can’t figure out how to handle them:

  1. I am not able to select the data in the views. If I use the SourceDataModel directly, no problem. But using the ProxySourceDataModel i can’t select anything.

  2. The data is not filtered at all! I overloaded data() in ProxySourceDataModel, and forward all the other calls to the underlying SourceDataModel. But still, only SourceDataModel::data() is called.

Here is some code to illustrate what I’m doing:

class SourceDataModel : public QAbstractItemModel
{
  //...
};

class ProxySourceDataModel : public SourceDataModel
{
public:
  ProxySourceDataModel(SourceDataModel& model)
    : model_(model)
  {
    // For all QAbstractItemModel's signals emitted by the underlying model,
    // I propagate them like this
    QObject::connect( &model_, SIGNAL(        the_signal()),
                      this,    SLOT  (forward_the_signal())) ;
  }

slots:
  void forward_the_signal()
  {
    emit the_signal();
  }

public:
  // For all QAbstractItemModel's virtual function, I do something like this
  virtual void the_function()
  {
    model_.the_function();
  }

  // This is where I was hoping to do the filtering
  virtual QVariant data( const QModelIndex& index,int role=Qt::DisplayRole )
  {
    return filter( model_.data(index,role) );
  }

private:
  SourceDataModel& model_;
};

SourceDataModel sourceDataModel;
QTableView      view;
view.setModel( new ProxySourceDataModel(sourceDataModel) );

Any help or advice greatly appreciated, thanks for reading!

——————– EDIT ————————

I found it!

The problem was that the view do not use QAbstractItemModel::data() from its model, but rather calls QModelIndex::data() on its items, which in turn calls the QAbstractItemModel::data() of the item’s underlying model.
And since my proxy returned model indexes from the underlying model, that is why the SourceDataModel::data() was always called instead of ProxySourceDataModel()!

I just reimplemented ProxySourceDataModel::index() to return local indexes, and it works like a charm.
Visit In QT, chaining models does not work as expected for more informations.

Thanks!

  • 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-20T20:53:17+00:00Added an answer on May 20, 2026 at 8:53 pm

    The problem was that the view do not use QAbstractItemModel::data() from its model, but rather calls QModelIndex::data() on its items, which in turn calls the QAbstractItemModel::data() of the item’s underlying model.
    And since my proxy returned model indexes from the underlying model, that is why the SourceDataModel::data() was always called instead of ProxySourceDataModel()!

    I just reimplemented ProxySourceDataModel::index() to return local indexes, and it works like a charm.
    Visit In QT, chaining models does not work as expected for more informations.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.