View Full Version : how to compare a Qstring with a constant char*
qt_user
9th August 2010, 12:44
I have to compare the text of a buton with a const , say for example "Set Homograph"...qstrcmp is showing error:
if(qstrcmp(localCalibrateControlsObj->setHomographyButton->text(),"Set Homography")==0)
ERROR:cannot convert QString to const cha *....
tbscope
9th August 2010, 12:54
You can use QString(const char* str) to convert it to a QString
borisbn
9th August 2010, 15:49
while QString has implicit constructor you can compare them with == operator
if ( localCalibrateControlsObj->setHomographyButton->text() == "Set Homography" ) ...
and if you want to compare with qstrcmp you should get a const char pointer to QString data like this
if ( qstrcmp( localCalibrateControlsObj->setHomographyButton->text().toAscii().constData(),"Set Homography")==0) ...
qt_user
10th August 2010, 03:42
thanx............thanx a lot
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.