I am beginner in Qt, my question is about move the file to another directory. Here is my code:
std::string file_orign = "/home/joshua/text.txt";
std::string file_target = "/home/joshua/test";
std::string mv_command = "mv "+file_orign+" "+file_target;
system(mv_command.c_str());
This one can work, but I need to get the file path and folder path from the text broswer, so I changed it.
std::string file_orign = ui->textBrowser1->toPlainText();
std::string file_target = ui->textBrowser2->toPlainText();
std::string mv_command = "mv "+file_orign+" "+file_target;
system(mv_command.c_str());
Then the error is that I need conversion from 'QString' to non-scalar type 'std::__cxx11::string. So I want to consult you all is there any qt function can work like system move function? I try the QDir::rename function but I did not find a format like
std::string mv_command = "mv "+file_orign+" "+file_target;
system(mv_command.c_str());
Another way is convert QString to std::string, but I think the first way is better. Hope someone can help me, thank you!
Sorry guys, all are my wrong, I asked a so unclear and so stupid question, I am so sorry for wasting your time, I am a beginner, before I asked this question, I really really had not noticed that this question was about the conversion from std::string to QString, because my level is to low. Because I am too naive, I can not ask question anymore, so please, please forgive me asked this question, I am too stress because I internship at a company, my project for me is quite hard so that I have no choice to do such a wasting your time thing, lastly, I want to say thank you for those who had seen my questions before.