首页 > 解决方案 > 我可以使用 qt 窗口内的小部件中的按钮运行外部程序吗?

问题描述

我正在使用 qt creator 在 Windows 10 上制作 ui。

我想使用按钮运行外部程序并将其放置在 qt 窗口内的小部件中。现在,当我单击按钮时,我创建了运行外部程序的代码,但程序只是出现在 qt 窗口之外。我可以使用 qt 窗口内的按钮运行外部程序并设置我想要的位置吗?我也一起上传了我的ui部分。

在此处输入图像描述

void MainWindow::on_pushButton_8_clicked()    
{    
    QProcess *process = new QProcess(this);
    QString file("D:\\My external file name");
    process->execute(file);
    QDesktopServices::openUrl(QUrl("file:///"+file,QUrl::TolerantMode));
}

标签: qtqt5

解决方案


推荐阅读