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. QWidget: Must construct a QApplication before a QWidget
Forum Updated to NodeBB v4.3 + New Features

QWidget: Must construct a QApplication before a QWidget

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 2.6k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    Ducking Ferp
    wrote on last edited by
    #1

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

    }@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

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

      @

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Ducking Ferp
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Ducking Ferp
            wrote on last edited by
            #5

            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)!

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Ducking Ferp
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andreyc
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  Ducking Ferp
                  wrote on last edited by
                  #8

                  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)!

                  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