Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to run gui and opengl from same process.

    General and Desktop
    3
    5
    1433
    Loading More Posts
    • 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.
    • Q
      Q139 last edited by Q139

      How to create two windows from same process so would have gui and also opengl window?

      ERROR MSG:
      ASSERT failure in QCoreApplication: "there should be only one application object", file kernel\qcoreapplication.cpp, line 721
      Invalid parameter passed to C runtime function.
      Invalid parameter passed to C runtime function.



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

      GLrun(0,0);

      return a.exec();
      

      }


      FAILS HERE:
      int GLrun(int argc, char **argv) <-- fail
      {

      QGuiApplication app(argc, argv);
      
      QSurfaceFormat format;
      format.setSamples(32);
      
      TriangleWindow window;
      window.setFormat(format);
      window.resize(800, 600);
      window.show();
      
      window.setAnimating(true);
      

      }


      How to have gui and opengl window work together correctly?

      1 Reply Last reply Reply Quote 0
      • C
        ChrisW67 last edited by ChrisW67

        Don't try to create a second application object (QCoreApplication or subclasses) in the GLrun() function and you will not get the message "there should be only one application object"

        If you do that then there is no need to pass the invalid argc/argv arguments.

        1 Reply Last reply Reply Quote 0
        • Q
          Q139 last edited by

          Can you please explain further or try sample on how to initialize opengl correctly with gui?

          1 Reply Last reply Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by Chris Kawa

            As @ChrisW67 said don't instantiate multiple Q*Applications:

            int main(int argc, char *argv[]) {
               QApplication a(argc, argv);
               MainWin w;
               w.show();
               
               QSurfaceFormat format;
               format.setSamples(32);
            
               TriangleWindow window;
               window.setFormat(format);
               window.resize(800, 600);
               window.setAnimating(true);
               window.show();
               
               return a.exec();
            }
            1 Reply Last reply Reply Quote 0
            • Q
              Q139 last edited by

              Thanks alot , it solved problems.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post