compare 2 QString, use == != ? or QString::compare ?
General and Desktop
4
Posts
4
Posters
20.6k
Views
2
Watching
-
wrote on 12 Mar 2015, 08:26 last edited by
compare 2 QString, use == != ? or QString::compare ?
which way is better and faster?
thank you -
wrote on 12 Mar 2015, 08:30 last edited by
I Think == is same QString::Compare because == call operator==() and compare also.
-
compare 2 QString, use == != ? or QString::compare ?
which way is better and faster?
thank youwrote on 12 Mar 2015, 08:39 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 ==
-
wrote on 12 Mar 2015, 08:43 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!=
1/4