How to change string into QString?

前端 未结 7 619
一向
一向 2020-11-28 03:36

What is the most basic way to do it?

相关标签:
7条回答
  • 2020-11-28 04:26

    Moreover, to convert whatever you want, you can use the QVariant class.

    for example:

    std::string str("hello !");
    qDebug() << QVariant(str.c_str()).toString();
    int test = 10;
    double titi = 5.42;
    qDebug() << QVariant(test).toString();
    qDebug() << QVariant(titi).toString();
    qDebug() << QVariant(titi).toInt();
    

    output

    "hello !"
    "10"
    "5.42"
    5
    
    0 讨论(0)
提交回复
热议问题