QWidget: Must construct a QApplication before a QWidget



  • So I'm having this problem with the error above and this is what is in the console:
    @QWidget: Must construct a QApplication before a QWidget
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.@

    This is my main(), if you need more code I will post more:
    @int main(int argc, char *argv[]){

    QApplication a(argc, argv);
    streamwindow w;
    QIcon icon(":/stuff/twitch_final.png");
    w.QWidget::setWindowIcon(icon);
    w.show();
    return a.exec();
    

    }@



  • call to setWindowIcon is incorrect
    @
    int main(int argc, char *argv[]){

        QApplication a(argc, argv);
        streamwindow w;
        QIcon icon(":/stuff/twitch_final.png");
        w.setWindowIcon(icon); // <<<<<<<<
        w.show();
        return a.exec(&#41;;
    }
    

    @



  • I still get the same error after I changed that. :/



  • Run it in step mode in a debugger to see what line generates the message.
    What line is it?
    Do you have any global variables that may use QWidget?



  • The debugger seems to go through it fine, as I see no messages be printed from it. I have not used QWidget in a global variable.

    What happens is it compiles the program fine, I can build it just fine, but when it comes time to actually run it is when it gives me the error.

    !http://i.imgur.com/PijYP8o.png(the error)!



  • If it helps at all the last thing I added was a bool that gets passed through a class. I also tested with another program and it works just fine, so there is nothing wrong with the compiler.



  • [quote author="Ducking Ferp" date="1409356830"]
    @
    QWidget: Must construct a QApplication before a QWidget
    @
    [/quote]
    This message is thrown by QWidget constructor and means that a pointer to QApplication is NULL

    [quote author="Ducking Ferp" date="1409356830"]
    @
    Invalid parameter passed to C runtime function.
    @
    [/quote]
    This message is thrown by Windows SDK and usually means that NULL pointer is passed to some C-function.

    Since you code generates run-time exception as a first step I would suggest to run distclean, qmake and build everything.
    Another option would be to check what libraries are in use when you start the app. Run dependency walker to see what DLLs your app is using.



  • I cannot figure out how to run distclean, but I have ran qmake and built everything.

    I ran dependency walker and this is what I found. !http://i.imgur.com/7EjPJjB.png(missing)!


Log in to reply
 

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