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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:09:37+00:00 2026-05-20T16:09:37+00:00

I am developing an application that updates the data in QTableView from apache server

  • 0

I am developing an application that updates the data in QTableView from apache server once per second. The server sends data as XML table. Number of columns is constant, but the number of rows changes each time. The data in the rows may also vary.

To convert the XML into the data, I created a class TxTableData, which is used in TxTableModel (child of QAbstractTableModel). Also TxTableModel uses QTimer to update data from the server.

The problem is that if the number of lines decreases – QTableview did not react to it. When the number of rows increases – it’s all right.

I need remove all rows from QTableView and fill it with new data, but QTableView does not do this. Can you

class TxTableModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    TxTableModel(QObject *parent = 0);

    void refreshData();
    void parseXml(const QByteArray &xml);

public slots:
    void httpDone(bool error);
    void timerDone();

protected:
    HttpConnect http;
    TxTableData m_Data;
    QTimer * timer;

};

TxTableModel::TxTableModel(QObject *parent) :
QAbstractTableModel(parent)
{
    timer = new QTimer(this);

    connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
    connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));

    timer->start(1000);
}

void TxTableModel::refreshData()
{
    TxRequest request;
    request.setObject("order");
    request.setMethod("getlist");
    request.addParam("begin_time", 60*60*4);
    request.addParam("end_time", 60*4);

    http.queryAsync(request);
}

void TxTableModel::parseXml(const QByteArray &xml)
{
    //qDebug() << xml;

    int count = m_Data.getRowCount();

    QXmlInputSource inputSource;
    QXmlSimpleReader reader;
    TxSaxTableHandler handler(&m_Data, false);

    inputSource.setData(xml);
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);

    beginResetModel();
    reader.parse(inputSource);
    endResetModel();
}

void TxTableModel::httpDone(bool error)
{
    if (error) {
        qDebug() << http.errorString();
    } else {
        parseXml(http.readAll());
    }
}

void TxTableModel::timerDone()
{
    refreshData();
}
  • 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-20T16:09:37+00:00Added an answer on May 20, 2026 at 4:09 pm

    It looks like you’re not providing the full source of TxTableModel model, as it’s missing implementation of rowCount, columnCount, data, setData, etc methods.

    As for the problem, my guess would be:

    1. As it was already suggested you can try cleaning the model before reloading it by calling removeRows(0, rowCount());

    2. in your removeRows implementation, you should call beginRemoveRows before updating the rows collection and endRemoveRows after you’re done. This should notify views about the model content change.

    There is an example on how to implement the QAbstractTableModel here: Address Book Example

    hope this helps, regards

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

Sidebar

Related Questions

I'm developing an application that gets large images from an Internet server which is
I am developing application that works with sql server, I read and update data
When developing an application that sends out notification email messages, what are the best
I'm developing an iPhone application which uses a TableView to display XML data. The
I'm developing an application that will be available from a website (market probably as
I'm developing and application that runs as a Windows service. There are other components
I'm developing an application that manages network interfaces on behalf of the user and
I am developing an application that needs to use regini (because of legacy reasons)
I am actually developing and application that has around 15 modules, all of them
We are developing an application that involves a lot of different tests where each

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.