[Development] Suggestion on QML portability

Olivier Goffart olivier at woboq.com
Mon Jul 16 10:56:56 CEST 2012


On Monday 16 July 2012 13:50:42 Alan Alpert wrote:
> It's a major version change, what did you expect? It's a pain to maintain
> even a QWidget application for a single Qt 4 and Qt 5 code-base, all the
> assistance I'm aware of is for porting Qt4 -> Qt5 in one go.

No it is not. Maintaining the same code base for Qt4 and Qt5 C++ Application 
is really easy. And that is because:

1) Qt5 is mostly source compatible: the methods have been deprecated, but not 
removed.

2) You have the preprocessor #if QT_VERSION ... that helps a lot for the few 
cases where there is a difference.


One of the main issue is the QtWidget include stuff, but you can do 
#include <QLineEdit> and you are good.  (The problem is that the porting tool 
uses QtWidget. (One could maybe add an option to the porting script)

Stephen's porting tool [https://github.com/KDAB/Qt4to5] already wrap the code 
into #if QT_VERSION ...



If you look at the past, some application kept their code compiling with 
different major version of Qt (KDevelop2 was working with Qt2 and Qt3)
Qt even works with different major version of some libraries like libopenssl 
or libpng with mostly the same code base (using preprocessor again)

-- 
Olivier

Woboq - Qt services and support - http://woboq.com



More information about the Development mailing list