[Qt-interest] Faster logfile viewer
Thomas Dähling
t.daehling at googlemail.com
Tue Aug 4 19:38:12 CEST 2009
Try using a QPlainTextEdit instead of a QTextEdit. Not sure how much
performance improvement it will bring (no Qt installed on this machine
so cannot test it) but it is supposed to be a lot faster since it's
position calculations are a lot simpler than those in QTextEdit.
Am 4. August 2009 17:24 schrieb Christoph Bartoschek <bartoschek at gmx.de>:
> 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
>
More information about the Qt-interest-old
mailing list