Use QString::indexOf. If the function returns 0, it starts with the other string.
Like this snippet:
#include <QApplication>
#include <QString>
#include <QtDebug>
int main(int argc, char* argv[])
{
int index;
index = foo.indexOf(bar);
qDebug() << index;
index = foo.indexOf(blubb);
qDebug() << index;
return app.exec();
}
#include <QApplication>
#include <QString>
#include <QtDebug>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QString foo("foobarblubb");
QString bar("foo");
QString blubb("bla");
int index;
index = foo.indexOf(bar);
qDebug() << index;
index = foo.indexOf(blubb);
qDebug() << index;
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks