Qt532.QString::split()

1、效果 和 JS里面 貌似是一样的

  1.1、QString 编码转换(https://www.cnblogs.com/CodeSkill/p/5082447.html)

2、代码:

void MainWindow::on_pushButton_2_clicked()
{
    QString str = "A B 10 2";
    QStringList strs = str.split(" ");
    for (int i=0; i)
        qDebug() << strs.at(i);
    qDebug() << "";


    str = "3   g  8    kjh 0";
    strs = str.split(" ");
    for (int i=0; i)
        qDebug() << strs.at(i);
    qDebug() << "";
}

  2.1、控制台输出

Starting E:\ZZ_Qt5\Qt532_vs2010\build-Test2-Desktop_Qt_5_3_MSVC2010_OpenGL_32bit-Release\release\Test2.exe...
"A"
"B"
"10"
"2"

"3"
""
""
"g"
""
"8"
""
""
""
"kjh"
"0"

 

3、

4、

5、

 

转载于:https://www.cnblogs.com/cppskill/p/9599212.html

你可能感兴趣的:(Qt532.QString::split())