QT中QString转换成int
时间: 2024-04-25 12:23:46 浏览: 195
在Qt中,可以使用QString类的toInt()方法将QString转换为int类型。例如:
QString str = "123";
int num = str.toInt();
这将把字符串"123"转换为整数类型的变量num。
#### 引用[.reference_title]
- *1* [Qt下QString与int 之间相互转换](https://blog.csdn.net/wangbaba_1/article/details/113034748)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [QString与基本数据类型如何转换?(Qt面试题)](https://blog.csdn.net/m0_56694518/article/details/131410375)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [QT中QString、string、int、char数据类型转换](https://blog.csdn.net/weixin_45726162/article/details/115530319)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文