[Interest] My experience porting to Qt5 (on OS X)
Konrad Rosenbaum
konrad at silmor.de
Wed Sep 12 21:16:47 CEST 2012
Hi,
On Wednesday 12 September 2012 19:16:29 Till Oliver Knoll wrote:
> Am 12.09.2012 um 17:47 schrieb Stephen Kelly <stephen.kelly at kdab.com>:
> > On Wednesday, September 12, 2012 16:20:01 Nikos Chantziaras wrote:
> >> Note that if you just do:
> >> #include <Whatever>
> >>
> >> then you can build with both Qt4 and Qt5.
> >
> > 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), even I /don't/ have QT += widgets?
>
> Whereas when I
>
> #include <QtWidgets/QWidget>
>
> it doesn't?!
No. It implies that with #include<QWidget> you get an outright compiler error
when you miss QT+=widgets while the project can still be compiled with Qt4
where it would be #include<QtGui/QWidget>.
> As for the "compile with Qt 4/5" part: I simply created a "qt5" Git branch.
> Once everything is stable there I merge everything back to "master". Works
> like a charm.
Another technique that I use:
To make the project link correctly to both Qt4 and Qt5 in the *.pro:
contains(QT_MAJOR_VERSION,"5") {
QT += widgets printsupport
}
And in the rare cases that APIs changed in *.cpp files:
QString subject=mycert.subjectInfo(QSslCertificate::CommonName)
#if QT_VERSION >= 0x50000
.value(0)
#endif
;
Konrad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120912/620036e6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120912/620036e6/attachment.sig>
More information about the Interest
mailing list