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. Newbie question
Qt 6.11 is out! See what's new in the release blog

Newbie question

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello everyone!!!
    I have a project using QtDesigner with VS10 win7 64bits and it works fine in debug mode but in release, it pop ups
    Must construct a QApplication before a QPaintDevice

    did I miss something during the installation, do I need to re install Qt??

    thank you for your help!!

    Massi

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      Neither nor. You just need to fix your code ;-)

      It's hard to say exactly without seeing your code. But make sure you create a QApplication object first before you do anything with Qt GUI widgets. Also try to find out where exactly in your code the warning/error is triggered.

      __

      From the docs:

      bq. For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the QtGui library.

      bq. Since the QApplication object does so much initialization, it must be created before any other objects related to the user interface are created. QApplication also deals with common command line arguments. Hence, it is usually a good idea to create it before any interpretation or modification of argv is done in the application itself.

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        thanks for your quick reply!
        my code is simple as:

        @#include "tomoregistration.h"
        #include <QtGui/QApplication>

        int main(int argc, char *argv[])
        {
        QApplication a(argc, argv);
        TomoRegistration w;
        w.show();
        return a.exec();
        }@

        As I said, it works fine on debug mode but on release, it stops at the following line:
        QtCored4.dll!qt_message_output(QtMsgType msgType, const char * buf) Line 2311 C++

        thx for your help

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          Your code looks okay, so far. Try to make a clean re-build.

          But: You don't have any statically initialized global variables, do you?

          Static initializes are run before main(), that's why I ask...

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Even with clean mode the problem still persists

            There is some global variables in tomoregistration.h:
            @extern std::vector<std::vector<double>> sourceLandmark;
            extern std::vector<std::vector<double>> targetLandmark;@

            and im my tomoregistration.cpp file I have
            @std::vector<std::vector<double>> sourceLandmark;
            std::vector<std::vector<double>> targetLandmark;@

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MuldeR
              wrote on last edited by
              #6

              That should be fine.

              Just don't make any global variables with Qt Widgets, as they would be created before the main() function and thus before QApplication is created.

              Again, I think you should track down where exactly in the program the error is triggered. E.g., step through your program line by line and find out the last line (command) that is executed before the error/warning appears...

              My OpenSource software at: http://muldersoft.com/

              Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

              Go visit the coop: http://youtu.be/Jay...

              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