PDA

View Full Version : Newbie - experiences with Qt



masoroso
3rd May 2006, 09:38
Hi all,

Here a short story on my Qt experiences as a complete Qt newbie.

The start
I am a geotechnical engineer and not so content with the software that is available because it is only available for Windows. I decided to write my own software for small tasks and it should be platform independent. I compared loads of libraries but because of the documentation and the professional Qt website I decided to use Qt. This was the start of qGEF, my first Qt based application that should be able to read GEF files which are used to graphically display the results of so called Cone Penetration Tests (CPT).

The problems
This is not my first application as I wrote a lot of applications using Delphi (from version 5 up to 2003). So what do you do if you switch to Qt... you look for an IDE :) I had no luck with an IDE (too buggy, no Qt support etc. etc.) so I fell back to Emacs, a console and QtDesigner and it gave me less problems than I expected.

QtDesigner is very user friendly though it's layout system is not so easy to understand if you are used to Borland's alClient, alLeft alignment options. In my opinion QtDesigner forces you to think of the layout in advance and not while you are playing with the RAD because it is more difficult to change the layout at a later phase. Overall I still have difficulty with the layout system but the examples are great and very helpful and so far I still manage to get it the way I want it to be. Implementing the ui file in a project was very easy again thanks to the great documentation.

What I expected to be a problem was the dynamic memory management but the QList and QVector classes were realy helpful and easy to manage. It was even easier than using the Delphi's classes (TList etc.). I do not have much C++ experience but it is quite easy to get a grip on the code (though I must admit I am still studying `thinking in C++' to get a real grip on the C++ language.

The other problem I feared was debugging the code but so far I easily manage to get things done using <QDebug>. For windows this required the installation of DbgView so it is possible to see the qDebug() output (the output is not shown in the commandline!). On linux using a console it is very easy to work with this option.

The coding
Emacs is a very nice editor (to say at least) and I preffered Emacs over Kate (KDE editor). There is no code completion but the syntax highlighting is ok and the other browser options (mouse-free :-) ) are great so I have no problems with using Emacs at all.

My application required a toolbar and using the action editor in QtDesigner this is (again) easy. The way QtDesigner handles this looks a lot like the Borland method so if you are used to that method it is no effort at all. Even assigning icons to the buttons is easy.

I subclassed the QtDesigner created ui header which was easy because of the samples in the documentation. The things I could not get right at first (expanding the main widget to window limits, setting up the slots and signal connections) were solved by either this forum or reading the documentation again.

My application needed to read a file with loads of data and this is again very easy with Qt. The QString class with things like `split' and toDouble() options are great. No difficulty at all. The data is stored using a QVector and this was way more convenient than using my standard Delphi TList solution. Qt offers great non-gui classes!

The other thing that my application needed and what I was very curious about was painting on a widget. This (again) turned out to be very easy. The QPainter is a powerful mechanism and it offered everything I needed. I even managed to offer a print to pdf function where all painting is done on the printer paintdevice (I had some difficulty in getting the scales right however :-) ). Zooming was just a matter of using painter.scale() so I did not have to do the `hard work' of calculating the new coordinates myself and even a tiny but nevertheless convenient thing like QRect's right() or width() option was available (in comparison a TRect in Delphi only consists of left, right, top, bottom which means that you will be calculating the width yourself very often.. the trolls already offer both options.. very well designed!)

Conclusion
Writing a Qt based application was (much) easier than I thought it would be. Most of the time so far was consumed setting up Qt under linux and windows and using different kinds of IDE's in combination with Qt. They all failed which was a bit of a letdown but as it turns out using Emacs and QtDesigner (and qDebug()!) works better than I thought. I am however curious if this would still be sufficient if a project gets realy large and realy deep into the core of Qt (debugging could get an issue then). This forum has been helpful even with questions that could possibly also be solved by looking at the manual :o so thanks for that.

Overall I realy like Qt and I am sure I will be using it for most of my GPL projects. I only wished the commercial license (€2.000 I was told!) was not so expensive so I could even write commercial software with Qt.. now I will fall back to Delphi (standard -> about €200,-) for commercial Windows-only applications but then.. the trolls have to earn some money to keep up their great work!

I Hope this was interesting to read, cheers!
Rob

a screenshot of my first Qt application so far
http://www.xs4all.nl/~masoroso/gfx/qgef.jpg

Glitch
3rd May 2006, 14:44
Rob,

Trolltech has a Small Business Program just for commercial startups like yourself. The discount is around 65% so that could bring your licenses fee to under E1000. Good luck with your project! Graphs are looking good!

http://www.trolltech.com/products/qt/smallbusiness.html

Justin Noel
justin@ics.com