Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    compare 2 QString, use == != ? or QString::compare ?

    General and Desktop
    4
    4
    17291
    Loading More Posts
    • 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.
    • O
      opengpu2 last edited by

      compare 2 QString, use == != ? or QString::compare ?
      which way is better and faster?
      thank you

      A 1 Reply Last reply Reply Quote 0
      • Malek_Khlif
        Malek_Khlif last edited by

        I Think == is same QString::Compare because == call operator==() and compare also.

        I Love Qt <3

        1 Reply Last reply Reply Quote 0
        • A
          Asperamanca @opengpu2 last edited by

          @opengpu2
          Compare gives you the option to ignore case. Also, operator== only gives you true or false, while compare can be used to sort strings.

          If all you want to do is check that two strings are absolutely equal, I would go for ==

          1 Reply Last reply Reply Quote 1
          • M
            mcosta last edited by

            IMO operator==() is faster because, as first thing, it checks if the sizes are the same.
            If you're interested only to test is the string are the same or not, go to == or !=

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply Reply Quote 3
            • First post
              Last post