[Qt-interest] Faster logfile viewer

Bill King bill.king at nokia.com
Wed Aug 5 05:31:01 CEST 2009


Personally, I've found that listviews are several orders of magnitude
faster for large logging displays.  Maybe a QStringList wrapped in a
QStringListModel with a QListView as the visual output.
This will be quickly extendable too if you wanted to say support icons
for the different levels of logtype (warning vs err vs diagnostic).

ext Christoph Bartoschek wrote:
> Hi,
>
> consider the program at the end of the post. It shows a TextEdit and a
> PushButton. When you press the button 10000 lines are appended to the
> TextEdit and the view is updated. The whole procedure takes 47 Seconds on
> my machine.
>
> Our old Motif application does the same within less then a second. How can I
> get a performace that is comparable to our old application with Qt?
>
> Thanks,
> Christoph
>
> main.cpp:
>
> #include <QApplication>
> #include "ama.hpp"
>
> int main(int argc, char ** argv) {
>    QApplication app(argc, argv);
>    Ama edit;
>    edit.show();
>    app.exec();
> }
>
> ama.hpp:
>
> #include <QtGui>
> #include <iostream>
>
> class Ama : public QTextEdit {
> Q_OBJECT
> public:
>      Ama();
> public slots:
>       void start();
> private:
>      QPushButton but;
> };
>
> ama.cpp:
>
> #include <iostream>
> #include "ama.hpp"
>
> Ama::Ama() : QTextEdit() {
>    but.show();
>    connect(&but, SIGNAL(clicked()), this, SLOT(start()));
> }
>
> void Ama::start() {
>    QTime time;
>    time.start();
>    for (int i = 0; i < 10000; ++i) {
>       QString str = QString("I ist %1").arg(i);
>       this->append(str);
>       repaint();
>    }
>    std::cout << "Elapsed " << time.elapsed()  / 1000.0<< std::endl;
> }
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
Bill King, Software Engineer
Qt Software, Nokia Pty Ltd
Brisbane Office




More information about the Qt-interest-old mailing list