[Qt-interest] Faster logfile viewer
Christoph Bartoschek
bartoschek at gmx.de
Tue Aug 4 19:24:08 CEST 2009
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;
}
More information about the Qt-interest-old
mailing list