PDA

View Full Version : QString Comparision Error



jagadeesh738
23rd May 2015, 08:43
Iam Comparing two QString Objects data using qstrcmp()

QString text = lineEdit->text();

while(!fp.atEnd()){
QString str=fp.readLine();
if(qstrcmp(str,text)==0)
qDebug("\n DATA EXISTS");
qDebug()<<""<<str;
}


Error:
finddialog.cpp:51:22: error: no matching function for call to ‘qstrcmp(QString&, QString&)’
/usr/local/TrollTech/include/QtCore/qbytearray.h:83:44: note: candidates are: int qstrcmp(const char*, const char*)
/usr/local/TrollTech/include/QtCore/qbytearray.h:84:44: note: int qstrcmp(const QByteArray&, const QByteArray&)
/usr/local/TrollTech/include/QtCore/qbytearray.h:85:44: note: int qstrcmp(const QByteArray&, const char*)
/usr/local/TrollTech/include/QtCore/qbytearray.h:86:19: note: int qstrcmp(const char*, const QByteArray&)
make: *** [finddialog.o] Error 1


pls kindly do the needfull..

ChrisW67
23rd May 2015, 10:10
I think the error message says it all. However, before you rush off and try to solve that problem perhaps you should ask yourself why you are trying to use qstrcmp() (which is a helper related to QByteArray) when QString has perfectly good equality operator?

wysota
23rd May 2015, 10:16
QString text = lineEdit->text();

while(!fp.atEnd()){
QString str=fp.readLine();
if(str == text)
qDebug("\n DATA EXISTS");
qDebug()<<""<<str;
}