QT小程序:QString

来源:互联网 发布:英文域名注册查询 编辑:程序博客网 时间:2024/04/30 23:27
#include <QCoreApplication>
#include <QString>
#include <QDebug>


using namespace std;


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);


    int x = 6;
    double y = 3.14159;
    char z = '$';


    QString qstr = QString("%1 %2 %3").arg(x).arg(y).arg(z);
    qDebug() << qstr;


    string str = "this is string.";
    qstr = str.c_str();
    qDebug() << qstr;


   qstr = "this is QString.";
   str = qstr.toStdString();
   qDebug() << str.c_str();


   qstr = "this is Qt.";
   qDebug() << qstr.contains("is");     // true
   qDebug() << qstr.contains("was");    // false


    return a.exec();
}
0 0
原创粉丝点击