PDA

View Full Version : Can i insert the external exe file window inside of GUI?



hajh90
24th July 2019, 04:51
I have created the code if i click push button, then the external exe file runs. But i want to place this external file window where i want inside of GUI with push button when i click push button. So that external file is moving together. Is it possible? Can anyone help me?

This is my code for push button to execute external file.

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));

}

shame
24th July 2019, 06:34
Try this :cool:


QString prog = "D:\\Program\\program.exe";
QStringList arg;
arg << "arg1" << "arg2";
QString workDir = "d:\\Program";
program->startDetached(prog, arg, workDir, 0);
WId hWnd = 0;
while (hWnd == 0)
{
hWnd = (WId) FindWindowW(NULL, L"D:\\Program\\program.exe");
}
window = QWindow::fromWinId(hWnd);
container = QWidget::createWindowContainer(window, ui->mdiArea);
QMdiSubWindow *subWindow = new QMdiSubWindow();
subWindow->setWidget(container);
subWindow->setAttribute(Qt::WA_DeleteOnClose);
subWindow->setWindowTitle("Program 1");
ui->mdiArea->addSubWindow(subWindow);
container->show();

hajh90
24th July 2019, 18:06
Try this :cool:


QString prog = "D:\\Program\\program.exe";
QStringList arg;
arg << "arg1" << "arg2";
QString workDir = "d:\\Program";
program->startDetached(prog, arg, workDir, 0);
WId hWnd = 0;
while (hWnd == 0)
{
hWnd = (WId) FindWindowW(NULL, L"D:\\Program\\program.exe");
}
window = QWindow::fromWinId(hWnd);
container = QWidget::createWindowContainer(window, ui->mdiArea);
QMdiSubWindow *subWindow = new QMdiSubWindow();
subWindow->setWidget(container);
subWindow->setAttribute(Qt::WA_DeleteOnClose);
subWindow->setWindowTitle("Program 1");
ui->mdiArea->addSubWindow(subWindow);
container->show();

Thanks a lot. What is "d:\\program" on 4th line? Directory of file? and program->startDetached, this code has error, use of undeclared identifier 'program'

QString prog = "D:\\Program\\program.exe";
QStringList arg;
arg << "arg1" << "arg2";
QString workDir = "d:\\Program";

shame
25th July 2019, 14:28
Working directory. Also add to .h file

WId id;
QProcess *program;
QWindow *window;
QWidget *container;