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. QEventLoop: Cannot be used without QApplication Qt static

QEventLoop: Cannot be used without QApplication Qt static

Scheduled Pinned Locked Moved Unsolved General and Desktop
30 Posts 6 Posters 10.9k 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by
    #15

    You never know if you have ifdef for windows. You need to identify the specific statement where this issue comes.

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    1 Reply Last reply
    1
    • M Offline
      M Offline
      Mohammedbie
      wrote on last edited by
      #16

      Yes on the windows we are using the native functions of the windows but it is used in Networking and logging only and the difference only in the includes and functions name.

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #17

        Since you say it is coming from RunSDK method, can you tell us which Qt classes you use inside this class. Where are you creating them ? Also you error is only following statement. Is that correct ?
        "QEventLoop: Cannot be used without QApplication"
        There is no "Qt Static" appended at the end.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        1
        • M Offline
          M Offline
          Mohammedbie
          wrote on last edited by Mohammedbie
          #18

          @dheerendra

          There are many levels in this function as I call other functions in it, the first level of the function uses :
          QString qDebug() QFile QSslCertificate QSslKey QList QByteArray QUuid QLoggingCategory QHash

          and yes the message is without "Qt Static" I added it as it only happens with Qt static.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mohammedbie
            wrote on last edited by
            #19

            I sill can't understand what cause this in Qt static and not in Qt dynamic of the same version as the code in the two cases the same .

            kshegunovK 1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by dheerendra
              #20

              I'm going back to basics. Can you create the simple Qt Project with your static Qt build & check if this works ? If this is not working we can see why it is so. Please note. By any chance

              1. By any chance QCoreApplication object what you are creating, is it getting destroyed ?
              2. Can you try handling destroyed.. signal like the follows in main.cpp
              QObject::connect(a,&QApplication::destroyed,[](){
                      qDebug() << Q_FUNC_INFO << " I am dying " << endl;}
                  );
              
              1. This error comes from only one source in Qt & it is QEventLoop. Issue can happen only if the QCoreApp instance is not created, created but destroyed.
              2. We have to just focus on the commenting out some code in RunSDK method & figure out.
              3. Since we don't have code, I'm proposing different possibilities to check the error.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              1
              • M Offline
                M Offline
                Mohammedbie
                wrote on last edited by
                #21

                @dheerendra
                That the first step I did after building Qt static I built a console application to test it and it ran with no problem then I ran SignalR tester to test SignalR and it ran without problems.
                I tried handling destroyed and "I am dying" never appeared as it should.
                I debugged the code in RunSDK method until the error appeared at a get function in SignalR code for getting a url.

                1 Reply Last reply
                0
                • dheerendraD Offline
                  dheerendraD Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on last edited by
                  #22

                  @Mohammedbie said in QEventLoop: Cannot be used without QApplication Qt static:

                  SignalR code for getting a url.

                  Do you mean that here you are using some QNework* classes to post the URL and get the response from webserver ?

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  1 Reply Last reply
                  1
                  • M Mohammedbie

                    I sill can't understand what cause this in Qt static and not in Qt dynamic of the same version as the code in the two cases the same .

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #23

                    @Mohammedbie said in QEventLoop: Cannot be used without QApplication Qt static:

                    I sill can't understand what cause this in Qt static and not in Qt dynamic of the same version as the code in the two cases the same .

                    The source may be the same, the way the generated binary/ies are run is different. The most significant difference is with globals/statics initialization. So if you have such, check them first.
                    Important: QCoreApplication must be the first QObject to be created and the last destroyed, which means you can't have global QObjects.

                    That's the best I can give you without source code or a stack trace (e.g. running a debug build with QT_FATAL_WARNINGS=1), or any additional information; I'm not about to just guess semi-randomly.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    2
                    • M Offline
                      M Offline
                      Mohammedbie
                      wrote on last edited by
                      #24

                      @dheerendra
                      Yes indeed and I tried opening the Last Get function in Qt creator but it didn't open so I couldn't trace at which line exactly in this function the error generated but I traced with "qDebug"s to it.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Mohammedbie
                        wrote on last edited by
                        #25

                        @kshegunov

                        I will check for global QObject s and Will give a stack trace as soon as possible.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Mohammedbie
                          wrote on last edited by
                          #26

                          @kshegunov

                          Stack trace :

                          1  __GI_raise              raise.c          51   0x7f5666f8ce97 
                          2  __GI_abort              abort.c          79   0x7f5666f8e801 
                          3  qt_message_fatal        qlogging.cpp     1680 0x7f566839a31e 
                          4  QMessageLogger::warning qlogging.cpp     560  0x7f566839596d 
                          5  QEventLoop::QEventLoop  qeventloop.cpp   103  0x7f56685265cc 
                          6  QThread::exec           qthread.cpp      506  0x7f56683a1e6d 
                          7  QThread::run            qthread.cpp      574  0x7f56683a2068 
                          8  QThreadPrivate::start   qthread_unix.cpp 344  0x7f56683aa1a1 
                          9  start_thread            pthread_create.c 463  0x7f56673466db 
                          10 clone                   clone.S          95   0x7f566706f88f
                          
                           The error message is generated in a get function for QNetworkAccessManager in SignalR.
                          
                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Mohammedbie
                            wrote on last edited by
                            #27

                            I tried something new , I tried building the SDK as a static library and it ran with Qt 5.7.0 static with no error on linux what can cause this ?

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              Mohammedbie
                              wrote on last edited by
                              #28

                              Any thought ?

                              1 Reply Last reply
                              0
                              • hskoglundH Offline
                                hskoglundH Offline
                                hskoglund
                                wrote on last edited by
                                #29

                                Hi, just guessing but the QCoreApplication a(argc, argv); call loads lots of stuff, like the Qt plugins, and if something fails your thread might start anyway, giving you that error because no healthy QCoreApplication is seen by the thread. Static builds depend on all the plugins are linked in properly, so it could be something missing for a static build (but the .so files are all present so your dynamic build runs fine).

                                1 Reply Last reply
                                4
                                • M Offline
                                  M Offline
                                  Mohammedbie
                                  wrote on last edited by
                                  #30

                                  @hskoglund
                                  Thanks for the reply. Will check the plugins built with Qt static and see if it built with success.

                                  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