View Full Version : QStringLiteral between qt4 and qt5

8th July 2014, 10:57
Hello everyone!
I have a question for you qt coder.
I am curently working on a qt widget, and I am developing it in two different os (ubuntu and fedora).
Ubuntu runs on qt5 and fedora on qt4.
I am trying to make the compilation on both os as smooth as possible.
So far I was able to achive that by using a couple of macro and variables like
Now qt 5 put in my ui_mainwindow.h the QStringLiteral which is new in qt5. Googling aroung I saw that if the compiler doesnt support c++ 11 the macro will fall back to QString::fromtUtf8.
My question is whats the best way to maintain backward compatibility?
Just replacing all QStringLiteral with QString::fromUtf8 or maybe try with a :
#define QStringLiteral QString::fromUtf8??
What you think is best?



8th July 2014, 11:22
That is not an issue here, ui_mainwindow.h is generated by UIC and the Qt4 UIC will not use QStringLiteral.


8th July 2014, 12:35
Thank you , how can I force the UIC to re-run from qt creator?
So I can get a new clean ui_mainwindow.h file qt4 compatible?
I tried to clean and rebuild etc but the ui_mainwindow.h file does not get regenerated

Added after 43 minutes:

Alright fixed the problem, desabiling shadow build in the project forced to rebuild the ui_mainwindow.h
I also paid attention to the :
** WARNING! All changes made in this file will be lost when recompiling UI file!

:D thanks man