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<strs.length(); i++)
        qDebug() << strs.at(i);
    qDebug() << "";


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

  2.1、控制台输出

Starting E:Z_Qt5Qt532_vs2010uild-Test2-Desktop_Qt_5_3_MSVC2010_OpenGL_32bit-Release
eleaseTest2.exe...
"A"
"B"
"10"
"2"

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

3、

4、

5、

原文地址:https://www.cnblogs.com/cppskill/p/9599212.html