QString contains 一个中文

#include <QtCore/QCoreApplication>
#include<QDebug>
#include <QTextCodec>
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
     QByteArray encodedString = "测试aabcc122";
     QTextCodec *codec = QTextCodec::codecForName("GBK");
     QString string = codec->toUnicode(encodedString);
     QString cc=codec->toUnicode(QByteArray("测试"));
     qDebug()<<string.contains(cc);
    return a.exec();
}

你可能感兴趣的:(contains)