[Interest] My experience porting to Qt5 (on OS X)

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Sep 12 21:31:33 CEST 2012


Am 12.09.2012 um 21:16 schrieb Konrad Rosenbaum <konrad at silmor.de>:

> Hi,
>  
> ....
> > >
> > > If you do this, you also avoid mysterious linking errors resulting from
> > > #include <QtWidgets/QWidget>
> >
> > Uhm... are you implying that when I
> >
> > #include <QWidget>
> >
> > that qmake automagically figures out that it needs to link with
> > "qtwidgets.dll" (or whatever the name), ...
>  
> No. It implies that with #include<QWidget> you get an outright compiler
> error when you miss QT+=widgets

Ah okay, got it ;) I was confused by the "mysterious linker error" part. Thanks for clarifying!

> while the project can still be compiled with Qt4 where it would be #include<QtGui/QWidget>.

As you noted in some cases you need #ifdefs anyway (in rare cases) as to bridge between Qt 4 and 5 API differences. I prefer to avoid them completely and maintain two Git branches instead: all new features go into "master" (Qt 4), merges and adaptions to Qt 5 are done in the Qt 5 branch - until at some point in the future that one is merged back to "master".

So I still prefer my "module imports" (which naturally also define a more structured #include order) :)

Cheers, Oliver







More information about the Interest mailing list