[Solved] Problem with indexOf

  • Hi

    I seem to be having problem with a QString.indexOf and Case Sensitivity.

    QString s("end = true");
    s.indexOf("End", Qt::CaseInsensitive); // will return a -1 item not found.
    s.indexOf("end", Qt::CaseInsensitive); // will return a 0 which is proper.

    Is there a oversight I'm not seeing or is this a Qt bug?

    OS = Linux, Qt5



  • The case sensitivity is the third parameter, not the second:
    1Of ( const QString & str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive ) const@


  • Hey! Thanks, completely overlooked that one, what are the chances that Qt::CaseInsensitive would be a enum that just happened to be a value of 0, no wonder the compiler passed it by.

    Thanks again!!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.