How to integrate a external openGL application (contain own main method) in QT?
-
That external application is a simulator 3D based on openGL that generate, when executed, your own graphical interface (own window) where you can manipulate an object, spinning, zooming, etc. What I need is integrate this application in a widget of my QT application, using all those funcionalities (spinning, zooming, etc the object) in that widget. I dont know what type of widget I could do that, but my guess is in a QOpenGLWidget. The other problem is how to do that. It's what I'm looking for. Can somebody help me with it?
When i run the QT application, it should show that external application, in a appropriate widget, with available those functionalities.
-
That external application is a simulator 3D based on openGL that generate, when executed, your own graphical interface (own window) where you can manipulate an object, spinning, zooming, etc. What I need is integrate this application in a widget of my QT application, using all those funcionalities (spinning, zooming, etc the object) in that widget. I dont know what type of widget I could do that, but my guess is in a QOpenGLWidget. The other problem is how to do that. It's what I'm looking for. Can somebody help me with it?
When i run the QT application, it should show that external application, in a appropriate widget, with available those functionalities.
@fabriciokash You can embed the UI of an external application in a Qt app. See https://forum.qt.io/topic/44091/embed-an-application-inside-a-qt-window-solved
But I'm not sure how well this works with OpenGL. -
@fabriciokash You can embed the UI of an external application in a Qt app. See https://forum.qt.io/topic/44091/embed-an-application-inside-a-qt-window-solved
But I'm not sure how well this works with OpenGL.@jsulm It can be a first step. Thanks a lot for answer.
If somebody could help too, will be greatfull
-
@JoeCFD What about it?
-
The approach that @jsulm suggested is the easiest: You have two different executables: your own executable and the OpenGL executable. Then you use the mentioned link to grab the window of the OpenGL executable and embed it into yours. It would be basically still two different programs with just the window rendered and moved and resized within your own windows. It is really hard to provide any interaction between the two. With this approach you do not need a QOpenGLWidget as the rendering is done by the other program. The link already provided has all the information you need for this approach.
-
The approach that @jsulm suggested is the easiest: You have two different executables: your own executable and the OpenGL executable. Then you use the mentioned link to grab the window of the OpenGL executable and embed it into yours. It would be basically still two different programs with just the window rendered and moved and resized within your own windows. It is really hard to provide any interaction between the two. With this approach you do not need a QOpenGLWidget as the rendering is done by the other program. The link already provided has all the information you need for this approach.
@SimonSchroeder Actually I read that approach, but I didn't understand. Sometimes he used some line of codes, but sometimes those lines are not there anymore.
I found this link using an approach like that.
https://stackoverflow.com/questions/33699258/qt-5-5-embed-external-application-into-qwidget
Basically i used the same code, with the difference Im not using a class of the specific widget that I want to embbed from. I just have a lot of widget in design file (ui extension) and used ui->widget which is the widget of interest (It's a QWidget class).
QWindow *window = QWindow::fromWinId(50331780); window->setFlags(Qt::FramelessWindowHint); QWidget *widget = QWidget::createWindowContainer(window); QVBoxLayout *layout = new QVBoxLayout(ui->widget); layout->addWidget(widget); ui->widget->setLayout(layout);
It works in parts. I tested embbeding the simple text editor gedit. The text editor's window really was embedded to my widget of interest, but its completely frozen. I can't edit the text inside of it or select part of the text or nothing like that, anything about interation. Another thing is happening is when i resize my main window (qt application), the text editor's window doesnt follow this resizing, showing a weird graphic interface on region sized
In image below, is the text editor inside my qwidget, but completely frozen.
The next image is the same execution, but tried to resize the qapplication window.
But a weird thing is happening. I tried to test the same configuration in unity, instead ubuntu. In unity, it works with no problem, almost perfectly.
What I mean about ubuntu and unity is in image below. On ubuntu config, it doesnt work, but works on unity config
Any suggestion about these problems?
-
@fabriciokash said in How to integrate a external openGL application (contain own main method) in QT?:
But a weird thing is happening. I tried to test the same configuration in unity, instead ubuntu. In unity, it works with no problem, almost perfectly.
To me your code looks fine and should work (as it does with Unity). Have you tried with both "Ubuntu" and "Ubuntu on Wayland"?
The problem with Linux is that every window manager works slightly differently with Qt and not all features are supported on all of them. So, it might actually be that it does not work on the Ubuntu window manager.
-
@fabriciokash said in How to integrate a external openGL application (contain own main method) in QT?:
But a weird thing is happening. I tried to test the same configuration in unity, instead ubuntu. In unity, it works with no problem, almost perfectly.
To me your code looks fine and should work (as it does with Unity). Have you tried with both "Ubuntu" and "Ubuntu on Wayland"?
The problem with Linux is that every window manager works slightly differently with Qt and not all features are supported on all of them. So, it might actually be that it does not work on the Ubuntu window manager.
@SimonSchroeder said in How to integrate a external openGL application (contain own main method) in QT?:
@fabriciokash said in How to integrate a external openGL application (contain own main method) in QT?:
But a weird thing is happening. I tried to test the same configuration in unity, instead ubuntu. In unity, it works with no problem, almost perfectly.
To me your code looks fine and should work (as it does with Unity). Have you tried with both "Ubuntu" and "Ubuntu on Wayland"?
The problem with Linux is that every window manager works slightly differently with Qt and not all features are supported on all of them. So, it might actually be that it does not work on the Ubuntu window manager.
Tried with Ubuntu on Wayland. The result was different and get other problems. To get the window ID, i was testing using one of these two commands, xdotool or xwininfo, and both can not recognize the text editor window. Used command "xwininfo -display :0" , he ask me to click on the window whose ID i want to get, but clicking on text editor window have no response, nothing happens. The same is happening using the command "xdotool selectwindow" or "xdotool -search --name "zzz"" (zzz is the file's name) or "xdotool -search --class "zzz"". Some windows, like mozilla firefox and qt, both commands recognize and returns to me the ID, but not for a simple text editor.
For mozilla and qt, i can embbed the windows to my qwidget and all works fine.
So, this is the resume of testing:
Ubuntu: It doesnt work with mozilla and text editor windows and standard folder (text editor and stand folder was embbed but without support of interation)
Ubuntu wayland: Works with mozilla and qt, but no for text editor and standard folder (text editor and folder wasnt even reconized by commands)
Unity: Aparently works with any window -
@SimonSchroeder said in How to integrate a external openGL application (contain own main method) in QT?:
@fabriciokash said in How to integrate a external openGL application (contain own main method) in QT?:
But a weird thing is happening. I tried to test the same configuration in unity, instead ubuntu. In unity, it works with no problem, almost perfectly.
To me your code looks fine and should work (as it does with Unity). Have you tried with both "Ubuntu" and "Ubuntu on Wayland"?
The problem with Linux is that every window manager works slightly differently with Qt and not all features are supported on all of them. So, it might actually be that it does not work on the Ubuntu window manager.
Tried with Ubuntu on Wayland. The result was different and get other problems. To get the window ID, i was testing using one of these two commands, xdotool or xwininfo, and both can not recognize the text editor window. Used command "xwininfo -display :0" , he ask me to click on the window whose ID i want to get, but clicking on text editor window have no response, nothing happens. The same is happening using the command "xdotool selectwindow" or "xdotool -search --name "zzz"" (zzz is the file's name) or "xdotool -search --class "zzz"". Some windows, like mozilla firefox and qt, both commands recognize and returns to me the ID, but not for a simple text editor.
For mozilla and qt, i can embbed the windows to my qwidget and all works fine.
So, this is the resume of testing:
Ubuntu: It doesnt work with mozilla and text editor windows and standard folder (text editor and stand folder was embbed but without support of interation)
Ubuntu wayland: Works with mozilla and qt, but no for text editor and standard folder (text editor and folder wasnt even reconized by commands)
Unity: Aparently works with any windowAlthough the solution had returned other problems, this topic will be marked as solved, because these problems is out of context of the topic. Thanks for contribution @SimonSchroeder , @jsulm , @JoeCFD.