Important: Please read the Qt Code of Conduct -

QString comparison?

  • Here a simple code.
    if (qstr==my_name)

    and the output :
    Why?????ID_REGISTER_NUMBER=Eng C. Born1=Eng C. Born1=
    It works in a smaller program.
    I just don't understand why it acts this way.
    Any suggestion?


  • Moderators

    Strange. You did not show us how you initialise those strings, though.

    Try running a QString::compare() on them to see what QString thinks about them.

  • OK, I find the bug. I can only see when I bring the code to Linux. TextEdit in Windows didn't print an extra char while on Linux it does print it out.
    But I still can not understand why the same codes work on the smaller program.
    Any how, the problem is solved.

    Thanks anyway.

  • Moderators

    Probably some codec issue. Be sure to store cpp files as UTF-8.

Log in to reply