Results 1 to 3 of 3

Thread: QString Comparision Error

  1. #1
    Join Date
    May 2015
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QString Comparision Error

    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..

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QString Comparision Error

    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?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QString Comparision Error

    Qt Code:
    1. QString text = lineEdit->text();
    2.  
    3. while(!fp.atEnd()){
    4. QString str=fp.readLine();
    5. if(str == text)
    6. qDebug("\n DATA EXISTS");
    7. qDebug()<<""<<str;
    8. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. String Comparision
    By parulkalra14 in forum Qt Programming
    Replies: 3
    Last Post: 28th January 2014, 07:06
  2. Parenthesis Comparision with Enter key Event
    By parulkalra14 in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2014, 10:39
  3. QString comparision with some different char
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 18th May 2013, 22:26
  4. Replies: 3
    Last Post: 27th July 2012, 09:30
  5. Replies: 2
    Last Post: 11th August 2011, 15:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.