QStringLiteral between qt4 and qt5

  • 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
    #if (QT_VERSION < QT_VERSION_CHECK(5 ,0 ,0))
    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?



  • Alright found the solution.
    Modifying the ui_mainwindow.h is not actually a solution since as the warning (** WARNING! All changes made in this file will be lost when recompiling UI file!) says all my changes will be trow away.
    So in the end this is not really a problem for the build since once that file is rebuild with qt4 the QStringLiteral wont be used.
    But I was not able to force UIC to run and rebuild the ui_mainwindow.h file so I had to disable shadow build in the project settings and looks like it fixed the problem

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.