Launching an application in Qt Widget



  • Hi,

    I tried to launch the application( any application in general with .exe or .out or other executable format) using the QProcess in Qt.

    I can simply launch the application there is no probelm in it , but i need to launch it in the main window rather than opening it in the seperate window, i tried google and found out there is -into and winId can be used to redirect the applicaion to specific window.
    But i could not get it worked .

    Below is the code i am using.

    Please some one let me know what am i doing wrong.

    main.cpp

    @
    #include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;

    w.show();
    
    return a.exec&#40;&#41;;
    

    }

    @

    mainwindow.cpp

    @#include "mainwindow.h"
    #include <QProcess>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    QProcess * proc = new QProcess(this);
    //proc->start("sol");// -into"+QString((int)this->winId()));
    proc->start("sol -into"+QString((int)parent->winId()));

    }

    MainWindow::~MainWindow()
    {

    }
    @

    mainwindow.h
    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QMainWindow>

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    };

    #endif // MAINWINDOW_H
    @



  • There is no (easy) way to do that. I doubt there is a reliable hard way to do it too, especially if the application you're running isn't made for this to work.



  • Its bad, i am just a beginner and finding its hard to get to know all the functions of Qt especially in customizing own UI.

    Is there any way to hide main window when the new window is launched and come to life when the new window is closed.

    if so please provide a some sample code or reference.



  • Perhaps you should consider telling us what you want to achieve, instead of trying to search for solutions around road blocks in routes that you have imagined to reach your goal.



  • You could do that very easy with QML.

    With widgets - not impossible but quite ugly. You could change your render method depending on whether the application is launched stand-alone or through another one, render to a offscreen paint device, put the result in the "parent process" widget geometry and forward the user input events and map as necessary. There might be pitfalls down the line, never done this myself but it should be doable. You will need some inter-process communication, some shared memory and some considerations made.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.