Results 1 to 4 of 4

Thread: Can i insert the external exe file window inside of GUI?

  1. #1
    Join Date
    Jul 2019
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Question Can i insert the external exe file window inside of GUI?

    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:n_pushButton_8_clicked()
    {
    QProcess *process = new QProcess(this);
    QString file("D:\\\My External File name");
    process->execute(file);
    QDesktopServices:penUrl(QUrl("file:///"+file,QUrl::TolerantMode));

    }

  2. #2
    Join Date
    Apr 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Can i insert the external exe file window inside of GUI?

    Try this
    Qt Code:
    1. QString prog = "D:\\Program\\program.exe";
    2. arg << "arg1" << "arg2";
    3. QString workDir = "d:\\Program";
    4. program->startDetached(prog, arg, workDir, 0);
    5. WId hWnd = 0;
    6. while (hWnd == 0)
    7. {
    8. hWnd = (WId) FindWindowW(NULL, L"D:\\Program\\program.exe");
    9. }
    10. window = QWindow::fromWinId(hWnd);
    11. container = QWidget::createWindowContainer(window, ui->mdiArea);
    12. QMdiSubWindow *subWindow = new QMdiSubWindow();
    13. subWindow->setWidget(container);
    14. subWindow->setAttribute(Qt::WA_DeleteOnClose);
    15. subWindow->setWindowTitle("Program 1");
    16. ui->mdiArea->addSubWindow(subWindow);
    17. container->show();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2019
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Can i insert the external exe file window inside of GUI?

    Quote Originally Posted by shame View Post
    Try this
    Qt Code:
    1. QString prog = "D:\\Program\\program.exe";
    2. arg << "arg1" << "arg2";
    3. QString workDir = "d:\\Program";
    4. program->startDetached(prog, arg, workDir, 0);
    5. WId hWnd = 0;
    6. while (hWnd == 0)
    7. {
    8. hWnd = (WId) FindWindowW(NULL, L"D:\\Program\\program.exe");
    9. }
    10. window = QWindow::fromWinId(hWnd);
    11. container = QWidget::createWindowContainer(window, ui->mdiArea);
    12. QMdiSubWindow *subWindow = new QMdiSubWindow();
    13. subWindow->setWidget(container);
    14. subWindow->setAttribute(Qt::WA_DeleteOnClose);
    15. subWindow->setWindowTitle("Program 1");
    16. ui->mdiArea->addSubWindow(subWindow);
    17. container->show();
    To copy to clipboard, switch view to plain text mode 
    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";

  4. #4
    Join Date
    Apr 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Can i insert the external exe file window inside of GUI?

    Working directory. Also add to .h file
    Qt Code:
    1. WId id;
    2. QProcess *program;
    3. QWindow *window;
    4. QWidget *container;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. insert hyperlink(URL) inside the TextEdit..
    By rleojoseph in forum Qt Programming
    Replies: 10
    Last Post: 6th January 2011, 08:15
  2. Replies: 0
    Last Post: 4th November 2009, 07:12
  3. Insert SVG inside QTextDocument
    By giusepped in forum Qt Programming
    Replies: 6
    Last Post: 23rd April 2009, 20:57
  4. [Qt4.1] How to insert an image inside a Form?
    By Gonzalez in forum Qt Tools
    Replies: 5
    Last Post: 23rd September 2008, 12:20
  5. Storing window geometry inside XML file.
    By GuS in forum Qt Programming
    Replies: 4
    Last Post: 17th July 2008, 14:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.