How to Compare two Qstrings ?

How to Compare two Qstrings ?

Asked on January 9, 2019 in Qt.
Add Comment


  • 2 Answer(s)

    By Comparing the  two Qstrings :

    int x = QString::compare(str1, str2, Qt::CaseInsensitive); // if strings are equal x should return 0
    
    
    Answered on January 9, 2019.
    Add Comment

    The alternative code is:

    int main(int argv, char **args)
     {
         QString str1="1005",str2="1006";
         if(str1 == str2)
             qDebug()<<"This should not print";
         qDebug()<<"Everything Ok";
    }
    

    Yield by:

    Everything Ok
    
    Answered on January 9, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.