Re: Framework Qt with c++
Andrea wrote:
I saw this framework and it seems very interesting (I have done some
tests with the Qt Creator editor and are positively surprised).
Does anyone use it? Opinions?
I have to use it in my company. My predecessor in my job had /everything/
entagled with Qt -- even low-level networking stuff, where, for example,
he used the quint8 data type as bytes.
I am somewhat ambiguous about Qt, because whereas it has some nice features
but I'd rather not use it. Some criticism in detail:
(1) Qt "extends" C syntax by provinding features like sigals, slots,
properties, etc. This leads to a huge amount of automatically generated
intermediate C++ files (moc_<classname>.cpp) that implement these language
extensions and are costly to compile. I often spend quite much time waiting
for the compiler to finish after having made minor changes. (Actually, I
suspect that this having to wait so much is also a design issue of our software).
(2) Qt defines elements that compete with STL, like QString, QMap, QList, etc.
Being a great fan of the STL I see no point why Qt tries to re-invented
the wheel. There also exist QThred, QFile, QDirectory, QApplication, qMax<T>, ...
(3) When you use the STL -- or templates in general -- (at least with Qt Creator
that came along Qt 4.8) you'll find out that the IDE is not aware of templates.
So when you have, say,
std::vector<Foo*> foos;
...
for ( std::vector<Foo*>::iterator i = foos.begin(), n = foos.end() ; i != n ; ++i ) {
(*i)// Typing continues here...
}
then the IDE does not recognise the type of *i for auto-completion (but it compiles well).
As I find auto-completion very helpful, in particular because it helps to avoid typing
errors, I often end up in ugly idioms like
for ( ... /*same as above*/ ) {
Foo * pFoo = *i;
pFoo// Typing continues here...
}
If I could decide at my own I'd only use Qt for the GUI and keep the application
logic itself completely Qt-free. Such a Qt-free model also gives you the freedom to port
the software to other windowing toolkits.
Norbert