How to change string into QString?

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

What is the most basic way to do it?

7条回答
  •  野性不改
    2020-11-28 04:16

    Alternative way:

    std::string s = "This is an STL string";
    QString qs = QString::fromAscii(s.data(), s.size());
    

    This has the advantage of not using .c_str() which might cause the std::string to copy itself in case there is no place to add the '\0' at the end.

提交回复
热议问题