QString 转 std::String
时间: 2023-11-02 11:20:08 浏览: 139
要将QString转换为std::string,可以使用QString的toStdString()方法。例如,通过以下代码可以实现QString到std::string的转换:
QString qstr = "Hello";
std::string str = qstr.toStdString();
这个代码将把qstr中的内容转换为std::string类型,并将结果存储在str中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [QString 与 std::string 互转](https://blog.csdn.net/aoxuestudy/article/details/115656127)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [VS2010+QT5编程之QString与char*的相互转换](https://blog.csdn.net/godmaycry/article/details/46372153)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文