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. QString comparison?
Forum Update on Monday, May 27th 2025

QString comparison?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.0k Views
  • 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.
  • I Offline
    I Offline
    IanBorn
    wrote on 22 Aug 2012, 10:43 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 22 Aug 2012, 10:55 last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • I Offline
        I Offline
        IanBorn
        wrote on 22 Aug 2012, 12:31 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 22 Aug 2012, 12:58 last edited by
          #4

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

          (Z(:^

          1 Reply Last reply
          0

          3/4

          22 Aug 2012, 12:31

          • Login

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