Starting an application and view its GUI inside QWidget (Linux)
-
@belal said in Starting an application and view its GUI inside QWidget (Linux):
that can execute processes given their paths
That's easy: QProcess.
and view the GUI of these processes inside the Qt application (Qwidget) as tabs
What "GUI" do these unspecified processes have under Linux?
-
rfb protocol. remote-frame-buffer.
-
@Kent-Dorfman
Thanks for the hint. -
@belal
You can run these viaQProcess
from your Qt application. They will open their own windows as they normally do.Firefox is a web browser. Qt offers the chromium embedded into a widget via
QWebEngine
, giving you a Chrome-like browser window if you would accept that instead of Firefox.If you can do any embedding of external windows have a look at e.g. https://stackoverflow.com/questions/33699258/qt-5-5-embed-external-application-into-qwidget, https://stackoverflow.com/questions/52608457/qt-5-11-embed-external-application-into-qwidget, etc.
-
@JonB said in Starting an application and view its GUI inside QWidget (Linux):
QProcess
The mentioned answers tends to move the started process GUI to the widget. I want to start a process and view the process GUI only inside the widget but the process will work out of my application.
-
@belal said in Starting an application and view its GUI inside QWidget (Linux):
I want to start a process and view the process GUI only inside the widget but the process will work out of my application.
That is exactly what it does!
-
@JonB
I need to display the GUI of the running QProcess inside the QWidget only. Not to embed the whole process inside the widget. For example I want to start detatchedgnome-calculator
from QProcess and this will rungnome-calculator
normally. Then display the GUI of the process inside a QWidget so whenever a change happens to the processgnome-calculator
I should see it inside the widget. -
@belal said in Starting an application and view its GUI inside QWidget (Linux):
I need to display the GUI of the running QProcess inside the QWidget only. Not to embed the whole process inside the widget.
Don't know what you mean, and will be surprised if @jsulm does either :)
Something run via
QProcess
is a separate process, period. The example code shows how you can cause its UI to appear inside a widget of yours in your app instead of its own window quite outside your Qt app. -
@belal said in Starting an application and view its GUI inside QWidget (Linux):
Not to embed the whole process inside the widget
You can't embed a process in a widget!
You can only embed the GUI of another application running in its own process in a widget.
And that is what @JonB suggested.
Really don't know what else to say here. -
@jsulm @JonB
I will show you the error that I get.#include "mainwindow.h" #include <QApplication> #include<QProcess> #include<QDesktopServices> #include<QUrl> #include<QWindow> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow *w = new QMainWindow(); w->setWindowTitle("Genome Embedded Calculator"); QWindow* window = QWindow::fromWinId(41943047); // Hardcoded Window Id for Genome Calculator window->setFlags(Qt::FramelessWindowHint); QWidget *widget = QWidget::createWindowContainer(window); w->setCentralWidget(widget); w->show(); return a.exec(); }
Here is the code that I am trying to run. I run the genome calculator and get it's WinId by using this command
xdotool search --pid [Genome_Calculator_Process_ID]
When I run the application I get an error in the terminal says:
(gnome-calculator:7284): Gtk-WARNING **: 16:03:49.869: gtk_widget_size_allocate(): attempt to allocate widget with width -33 and height 46 (gnome-calculator:7284): Gtk-WARNING **: 16:03:49.869: Negative content width -25 (allocation 1, extents 13x13) while allocating gadget (node button, owner GtkMenuButton) (gnome-calculator:7284): Gdk-WARNING **: 16:03:57.145: GdkWindow 0x2800007 unexpectedly destroyed (gnome-calculator:7284): GLib-GObject-WARNING **: 16:03:57.145: invalid (NULL) pointer instance (gnome-calculator:7284): GLib-GObject-CRITICAL **: 16:03:57.145: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed (gnome-calculator:7284): Gdk-CRITICAL **: 16:03:57.145: gdk_frame_clock_end_updating: assertion 'GDK_IS_FRAME_CLOCK (frame_clock)' failed
-
@belal
No idea. Maybe a problem with Gtk/Gdx/gnome-calculator running in the way. Maybe Firefox would work, maybe not. That stackoverflow post shows you what you can do run an external application with input/output to a widget, that's all I know.