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 run gui and opengl from same process.
QtWS25 Last Chance

How to run gui and opengl from same process.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.7k 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.
  • Q Offline
    Q Offline
    Q139
    wrote on last edited by Q139
    #1

    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
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      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
      0
      • Q Offline
        Q Offline
        Q139
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          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
          0
          • Q Offline
            Q Offline
            Q139
            wrote on last edited by
            #5

            Thanks alot , it solved problems.

            1 Reply Last reply
            0

            • Login

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