How to run gui and opengl from same process.



  • 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?



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



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


  • Moderators

    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();
    }


  • Thanks alot , it solved problems.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.