QString comparison?



  • Here a simple code.
    @
    if (qstr==my_name)
    ui->textEdit_In->append(tr("ID_REGISTER_NUMBER=%1=%2=").arg(my_name).arg(qstr));else
    ui->textEdit_In->append(tr("Why?????ID_REGISTER_NUMBER=%1=%2=").arg(my_name).arg(qstr));
    @

    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?

    Thanks.


  • 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
 

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