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. Application crash with ASSERT error
QtWS25 Last Chance

Application crash with ASSERT error

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 620 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.
  • D Offline
    D Offline
    danymt
    wrote on last edited by
    #1

    I have this error when closing the application, but I am not using QCoreApplication, QChart or Qml. Could you tell me any possible solution?

    ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1038 | kernel\qapplication.cpp:1038

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Welcome to the Qt Forum.

      We cannot possibly guess what your code is doing.
      Can you tell us what you are using rather than what you are not using? Better still post the actual code around where you use QApplication or QGuiApplication, typically main().

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

        @ChrisW67
        The code is too long, but I am using Qt 5.12 on Windows 10, and the error began when I upgraded the code from Qt 4.7 to Qt 5, before that, it worked fine.

        Thanks for answering

        JonBJ 1 Reply Last reply
        0
        • D danymt

          @ChrisW67
          The code is too long, but I am using Qt 5.12 on Windows 10, and the error began when I upgraded the code from Qt 4.7 to Qt 5, before that, it worked fine.

          Thanks for answering

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @danymt
          The error message tells you that you are trying to use some "style" but have not created a QApplication instance yet, at least at the instant the style code is being hit. You need to create that in a Qt UI program. I cannot say why it did work prior to Qt5.

          You can see the error at https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qapplication.cpp.html#1037, which looks like:

          /*!
              Returns the application's style object.
              \sa setStyle(), QStyle
          */
          QStyle *QApplication::style()
          {
              if (QApplicationPrivate::app_style)
                  return QApplicationPrivate::app_style;
              if (!qobject_cast<QApplication *>(QCoreApplication::instance())) {
                  Q_ASSERT(!"No style available without QApplication!");
                  return 0;
              }
          
          1 Reply Last reply
          1
          • D Offline
            D Offline
            danymt
            wrote on last edited by
            #5

            I already found the problem.
            I was using an object: QApplication app(argc, argv);
            instead of a pointer: QApplication* app = new QApplication(argc, argv);

            Using the pointer, everything worked fine.
            Thank you all.

            JonBJ 1 Reply Last reply
            0
            • D danymt

              I already found the problem.
              I was using an object: QApplication app(argc, argv);
              instead of a pointer: QApplication* app = new QApplication(argc, argv);

              Using the pointer, everything worked fine.
              Thank you all.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @danymt
              That is actually a bit worrying, as QApplication app(argc, argv); should be fine and is in fact the way you will see in most examples. The question is: where do you put this? It should be in main(), so scope/lifetime will be fine. Do/did you have it elsewhere, so that it went out of scope?

              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