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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:57:49+00:00 2026-05-27T12:57:49+00:00

I need a table GUI control that is able to quickly add and show

  • 0

I need a table GUI control that is able to quickly add and show around 100’000 items.
For this reason, “virtual” table control is needed, that loads and shows only visible items.
I tried QTableView and QAbstractTableModel:

class MyModel : public QAbstractTableModel
{
public:
MyModel(QObject * parent, IDataSource* dataSource) 
    : QAbstractTableModel(parent), m_dataSource(dataSource) {}

int rowCount(const QModelIndex& parent = QModelIndex()) const
{
    return m_dataSource->rowCount();
}

int columnCount(const QModelIndex& parent = QModelIndex()) const
{
    return 3;
}

QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
{
    if (role == Qt::DisplayRole)
    {
            return m_dataSource->cell(index.row(), index.column());
    }
    return QVariant();
}

bool addItem()
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    endInsertRows();
    return true;
}

private:
IDataSource* m_dataSource;
};

...

MyModel* model = new MyModel(this, this);
m_ui.tableView->setModel(model);
m_ui.tableView->show();

The problem is that MyModel::data() is called when adding new items out of visible area. And this makes a big slow in performance.
This is my test scenario to be more specific:

  1. View is created with only 5 elements that can be visible at one time.
  2. I add 20 items with MyModel::addItems.
  3. MyModel::data is called for all visible items.
  4. MyModel::data continues to be called for visible items (1…5) when items 6, 7, 9 … 20 are added.

I was thinking maybe this can be caused by vertical scrollbar that is redrawn when adding new items and seems to make all QListView redraw. But after hiding vertical scrollbar the issue remained.
Please suggest.

  • 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-27T12:57:49+00:00Added an answer on May 27, 2026 at 12:57 pm

    I didn’t find out how to prevent endInsertRows call to cause extra invocations of data() method. But calling endInsertRows once for multiple items solves the performance problem. So i call:

    beginInsertRows(QModelIndex(), rowCount(), rowCount() + 1000);
    endInsertRows();
    

    instead of calling for 1000 times:

    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    endInsertRows();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found this excel add-in to buy that appears to do what I need,
I need a table that stores key-value pairs, so I created one with a
I know that table sources need a data source to hold the data that
I need a select from table which does not have column that tells when
I need table with editable cells for my Android app. Something like QTableWidget in
I need a table to store the state of a financial transaction. The state
I need a table where rows are actually 2 rows tables, a nested table
I am developing an iPad application in which I need a table view (
I need a simple table with a user name and password field in MySQL.
My table's records need to satisfy two conditions: Entries in the ClosingDate field cannot

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.