I'm in the process of trying to figure out how to launch a windows application in Qt. What I'm trying to accomplish is for the user to click on a button and the notepad windows application opens. I understand that their is a notepad feature in Qt, but I looking for a different way to do this. I want to possible be able to do this with any windows application. Does anyone have any hint on how I can accomplish this?
Qt
has special class QProcess
which allows you to do this.
For example:
void MainWindow::on_pushButton_clicked()
{
QProcess *proc = new QProcess(this);
proc->start("notepad.exe");
}
There are many useful methods in this class. Check it in the documentation:
http://qt-project.org/doc/qt-5/QProcess.html
Also you can open file in this app. Just use:
proc->start("notepad.exe path");
where path
is something like this: G:/test.txt
To use this class you should #include <QProcess>
你可以使用QProcess类,看看start或startDetached ,例如:
QProcess::startDetached("notepad.exe");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.