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();
}
@
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_OBJECTpublic:
MainWindow(QWidget *parent = 0);
~MainWindow();
};#endif // MAINWINDOW_H
@ -
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.
-
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.