简体   繁体   English

Qt-使用用户文本输入直接定向到文件夹

[英]Qt - Using user text input to direct to folder

Is there a way to include user text input in a file address? 有没有办法在文件地址中包含用户文本输入? For example: 例如:

The user inputs a first and last name, and it is saved as Qstrings firstname and lastname . 用户输入firstnamelastname ,并将其另存为Qstrings firstnamelastname I want to then access a folder that is named firstname_lastname (Ex: John_Doe`), saved in location like this one: 然后,我想访问一个名为firstname_lastname (Ex: John_Doe`)的文件夹,该文件夹保存在这样的位置:

C://Users/User/Documents/Patients/firstname_lastname

How would I go about using those strings to direct to that folder? 我将如何使用这些字符串定向到该文件夹​​?

Use arg() 使用arg()

qDebug() << QString("C:/Users/User/Documents/Patients/%1_%2")
.arg(ui->lineEdit->text())    //firstname
.arg(ui->lineEdit_2->text()); //lastname

I don't know what exatly you want, but you can use this to open directory. 我不知道您想要什么,但是您可以使用来打开目录。 Or you can use QDir 或者您可以使用QDir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM