qt-interest@trolltech.com
[Top] [All Lists]

[Qt-interest] Faster logfile viewer

Subject: [Qt-interest] Faster logfile viewer
From: Christoph Bartoschek
Date: Tue, 04 Aug 2009 19:24:08 +0200
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@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest

<Prev in Thread] Current Thread [Next in Thread>