Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStringLiteral between qt4 and qt5
Forum Updated to NodeBB v4.3 + New Features

QStringLiteral between qt4 and qt5

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    giordi
    wrote on last edited by
    #1

    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))
    etc.
    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?

    Cheers

    M.

    Coding is powaaaaa

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giordi
      wrote on last edited by
      #2

      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

      Coding is powaaaaa

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved