Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to integrate a external openGL application (contain own main method) in QT?
QtWS25 Last Chance

How to integrate a external openGL application (contain own main method) in QT?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fabriciokash
    wrote on 26 Sept 2021, 21:56 last edited by fabriciokash
    #1

    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.

    J 1 Reply Last reply 27 Sept 2021, 05:42
    0
    • F fabriciokash
      26 Sept 2021, 21:56

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 27 Sept 2021, 05:42 last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply 27 Sept 2021, 06:57
      2
      • J jsulm
        27 Sept 2021, 05:42

        @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.

        F Offline
        F Offline
        fabriciokash
        wrote on 27 Sept 2021, 06:57 last edited by fabriciokash
        #3

        @jsulm It can be a first step. Thanks a lot for answer.

        If somebody could help too, will be greatfull

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JoeCFD
          wrote on 27 Sept 2021, 15:56 last edited by JoeCFD
          #4

          create OpenGL scene with QOpenGLFunctions in your own subclass of QOpenGLWidget

          F 1 Reply Last reply 28 Sept 2021, 03:03
          1
          • J JoeCFD
            27 Sept 2021, 15:56

            create OpenGL scene with QOpenGLFunctions in your own subclass of QOpenGLWidget

            F Offline
            F Offline
            fabriciokash
            wrote on 28 Sept 2021, 03:03 last edited by
            #5

            @JoeCFD What about it?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SimonSchroeder
              wrote on 28 Sept 2021, 07:13 last edited by
              #6

              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.

              F 1 Reply Last reply 3 Oct 2021, 18:03
              1
              • S SimonSchroeder
                28 Sept 2021, 07:13

                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.

                F Offline
                F Offline
                fabriciokash
                wrote on 3 Oct 2021, 18:03 last edited by fabriciokash 10 Mar 2021, 18:42
                #7

                @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.

                Screenshot from 2021-10-03 14-58-01.png

                The next image is the same execution, but tried to resize the qapplication window.

                Screenshot from 2021-10-03 15-10-22.png

                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

                photo_2021-10-03_15-41-54.jpg

                Any suggestion about these problems?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SimonSchroeder
                  wrote on 4 Oct 2021, 07:49 last edited by
                  #8

                  @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.

                  F 1 Reply Last reply 4 Oct 2021, 11:13
                  1
                  • S SimonSchroeder
                    4 Oct 2021, 07:49

                    @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.

                    F Offline
                    F Offline
                    fabriciokash
                    wrote on 4 Oct 2021, 11:13 last edited by fabriciokash 10 Apr 2021, 11:33
                    #9

                    @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

                    F 1 Reply Last reply 7 Oct 2021, 19:29
                    0
                    • F fabriciokash
                      4 Oct 2021, 11:13

                      @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

                      F Offline
                      F Offline
                      fabriciokash
                      wrote on 7 Oct 2021, 19:29 last edited by
                      #10

                      Although 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.

                      1 Reply Last reply
                      0

                      7/10

                      3 Oct 2021, 18:03

                      • Login

                      • Login or register to search.
                      7 out of 10
                      • First post
                        7/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved