note: This page will contain code snippets of all QString functions

QString::endsWith()
Returns true if the string ends with s; otherwise returns false.

  1. #include <QTextStream>
  2. #include <QString>
  3.  
  4. int main()
  5. {
  6.    QTextStream out(stdout);
  7.    QString *string = new QString("example-0.0.1.tar.gz");
  8.  
  9.    if (string->endsWith(".tar.gz") == true) {
  10.        out << "True\n";
  11.    } else {
  12.        out << "False\n";
  13.    }
  14. }