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. Why console prompt: QEventLoop: Cannot be used without QApplication?
Forum Updated to NodeBB v4.3 + New Features

Why console prompt: QEventLoop: Cannot be used without QApplication?

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 7 Posters 3.0k Views 3 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.
  • C Offline
    C Offline
    canid
    wrote on last edited by
    #1

    I use QEventLoop in my program, but it prompts me when I enter the main function and haven't called QEventLoop yet

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you show the code you are using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • C Offline
        C Offline
        canid
        wrote on last edited by canid
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Can you show the code you are using ?

          C Offline
          C Offline
          canid
          wrote on last edited by JKSH
          #4

          @SGaist
          The code is as follows:

          # include < QApplication >
          # include < QSettings >
          # include < qfile. H >
          # include "tool/enum. H"
          # include < dialog/dlg_reg. H >
          # include "dialog/dlg_login. H"
          # include "window_main. H"
          Int main(int argc, char *argv[])
          {
          QApplication app (arg c, argv);
          QFile file (" : / QSS/white QSS ");
          The file open (QFile: : ReadOnly);
          QString styleSheet = QLatin1String (file. ReadAll ());
          App. SetStyleSheet (styleSheet);
          }
          

          I follow these steps:
          Build-> Clean Project 'XYZ'
          The Build - > Run qmake
          Build-> Build Project 'XYZ'
          It still says:
          QEventLoop: Cannot be used without QApplication

          [EDIT: Added code formatting around source code --JKSH]

          JKSHJ 1 Reply Last reply
          -1
          • C canid

            @SGaist
            The code is as follows:

            # include < QApplication >
            # include < QSettings >
            # include < qfile. H >
            # include "tool/enum. H"
            # include < dialog/dlg_reg. H >
            # include "dialog/dlg_login. H"
            # include "window_main. H"
            Int main(int argc, char *argv[])
            {
            QApplication app (arg c, argv);
            QFile file (" : / QSS/white QSS ");
            The file open (QFile: : ReadOnly);
            QString styleSheet = QLatin1String (file. ReadAll ());
            App. SetStyleSheet (styleSheet);
            }
            

            I follow these steps:
            Build-> Clean Project 'XYZ'
            The Build - > Run qmake
            Build-> Build Project 'XYZ'
            It still says:
            QEventLoop: Cannot be used without QApplication

            [EDIT: Added code formatting around source code --JKSH]

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @canid said in Why console prompt: QEventLoop: Cannot be used without QApplication?:

            # include < QApplication >
            # include < QSettings >
            # include < qfile. H >
            # include "tool/enum. H"
            # include < dialog/dlg_reg. H >
            # include "dialog/dlg_login. H"
            # include "window_main. H"
            Int main(int argc, char *argv[])
            {
            QApplication app (arg c, argv);
            QFile file (" : / QSS/white QSS ");
            The file open (QFile: : ReadOnly);
            QString styleSheet = QLatin1String (file. ReadAll ());
            App. SetStyleSheet (styleSheet);
            }
            

            This code cannot compile. Please copy + paste the actual code from your project.

            Also, show the code for your enum, dialog, and window.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            C 1 Reply Last reply
            4
            • JKSHJ JKSH

              @canid said in Why console prompt: QEventLoop: Cannot be used without QApplication?:

              # include < QApplication >
              # include < QSettings >
              # include < qfile. H >
              # include "tool/enum. H"
              # include < dialog/dlg_reg. H >
              # include "dialog/dlg_login. H"
              # include "window_main. H"
              Int main(int argc, char *argv[])
              {
              QApplication app (arg c, argv);
              QFile file (" : / QSS/white QSS ");
              The file open (QFile: : ReadOnly);
              QString styleSheet = QLatin1String (file. ReadAll ());
              App. SetStyleSheet (styleSheet);
              }
              

              This code cannot compile. Please copy + paste the actual code from your project.

              Also, show the code for your enum, dialog, and window.

              C Offline
              C Offline
              canid
              wrote on last edited by
              #6

              @JKSH
              I didn't refer to QEventLoop, why is there a hint about it?

              aha_1980A 1 Reply Last reply
              0
              • C canid

                @JKSH
                I didn't refer to QEventLoop, why is there a hint about it?

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @canid you probably have a global QObject variable somewhere.

                Without code, nobody can tell you.

                Qt has to stay free or it will die.

                C 1 Reply Last reply
                4
                • aha_1980A aha_1980

                  @canid you probably have a global QObject variable somewhere.

                  Without code, nobody can tell you.

                  C Offline
                  C Offline
                  canid
                  wrote on last edited by canid
                  #8

                  @aha_1980 @JKSH
                  I looked at other people's published topics, and there was no one who couldn't solve the problem without uploading the source code

                  jsulmJ 1 Reply Last reply
                  -1
                  • C canid

                    @aha_1980 @JKSH
                    I looked at other people's published topics, and there was no one who couldn't solve the problem without uploading the source code

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #9

                    @canid That really doesn't mean that your question can be answered without source code. In this case there already was a suggestion what to check: "global QObject variable somewhere" - did you check? If not then please do. If you want others to check that then please post your source code the only other thing others can do is guessing...

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    3
                    • C Offline
                      C Offline
                      canid
                      wrote on last edited by canid
                      #10

                      @JKSH @jsulm
                      Come on, why are you so hard on a novice?Why do you upvote each other and downvote me?Why is it necessary to downvote even the posted code?

                      jsulmJ 1 Reply Last reply
                      0
                      • C canid

                        @JKSH @jsulm
                        Come on, why are you so hard on a novice?Why do you upvote each other and downvote me?Why is it necessary to downvote even the posted code?

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by jsulm
                        #11

                        @canid I don't know who downvoted your posts, I did not. I only downvote posts where the poster behaves rude.
                        But you should be aware that asking for help for programming issues/questions and then saying that code is actually not necessary because somewhere else questions were answered without code isn't a good idea. Sometimes you can answer a question without code, but sometimes you can only guess what could be wrong (as it was already the case here with the global QObject, did you check by the way? I'm asking this question second time now) if you cannot see the actual code. And actually you will see allot of code in topics here and you will see that others often ask for code, nothing special, really. Programming errors are done in code, so code is often essential to find an issue.
                        And why do you refuse to post the code? Is it secret?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        C 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @canid I don't know who downvoted your posts, I did not. I only downvote posts where the poster behaves rude.
                          But you should be aware that asking for help for programming issues/questions and then saying that code is actually not necessary because somewhere else questions were answered without code isn't a good idea. Sometimes you can answer a question without code, but sometimes you can only guess what could be wrong (as it was already the case here with the global QObject, did you check by the way? I'm asking this question second time now) if you cannot see the actual code. And actually you will see allot of code in topics here and you will see that others often ask for code, nothing special, really. Programming errors are done in code, so code is often essential to find an issue.
                          And why do you refuse to post the code? Is it secret?

                          C Offline
                          C Offline
                          canid
                          wrote on last edited by
                          #12

                          @jsulm
                          Please give an example to show that not uploading source code does not solve the problem.I have posted the main function code, how can you say there is no code

                          J.HilkJ jsulmJ JKSHJ 3 Replies Last reply
                          0
                          • C canid

                            @jsulm
                            Please give an example to show that not uploading source code does not solve the problem.I have posted the main function code, how can you say there is no code

                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by
                            #13

                            @canid said in Why console prompt: QEventLoop: Cannot be used without QApplication?:

                            @jsulm
                            Please give an example to show that not uploading source code does not solve the problem.

                            this thread.

                            I have posted the main function code, how can you say there is no code

                            let me quote @JKSH

                            This code cannot compile. Please copy + paste the actual code from your project.
                            Also, show the code for your enum, dialog, and window


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            1 Reply Last reply
                            1
                            • C canid

                              @jsulm
                              Please give an example to show that not uploading source code does not solve the problem.I have posted the main function code, how can you say there is no code

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by jsulm
                              #14

                              @canid said in Why console prompt: QEventLoop: Cannot be used without QApplication?:

                              Please give an example to show that not uploading source code does not solve the problem

                              Sorry, but I will not, you can search by yourself if you don't believe me (I am in this forum since many years already, so I'm speaking from my own experience, based on what do you make your claims?). I really wonder why you think that programming issues can always be solved without checking source code (not much experience in software development I guess?)? What do you expect from other people here? That they use a crystal ball or some other magic to find out where in your code the issue is?

                              "main function code" - there is more code in your project...

                              "how can you say there is no code" - I did not, I and others are asking you to post more of your code not just main.

                              I will ask for the third (and last time): did you check whether there is any global/static QObject somewhere in your code?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              C 1 Reply Last reply
                              1
                              • jsulmJ jsulm

                                @canid said in Why console prompt: QEventLoop: Cannot be used without QApplication?:

                                Please give an example to show that not uploading source code does not solve the problem

                                Sorry, but I will not, you can search by yourself if you don't believe me (I am in this forum since many years already, so I'm speaking from my own experience, based on what do you make your claims?). I really wonder why you think that programming issues can always be solved without checking source code (not much experience in software development I guess?)? What do you expect from other people here? That they use a crystal ball or some other magic to find out where in your code the issue is?

                                "main function code" - there is more code in your project...

                                "how can you say there is no code" - I did not, I and others are asking you to post more of your code not just main.

                                I will ask for the third (and last time): did you check whether there is any global/static QObject somewhere in your code?

                                C Offline
                                C Offline
                                canid
                                wrote on last edited by canid
                                #15

                                @jsulm
                                You are so obsessive that you focus on something other than the problem rather than the problem itself. It doesn't help solve the problem

                                jsulmJ 1 Reply Last reply
                                0
                                • C canid

                                  @jsulm
                                  You are so obsessive that you focus on something other than the problem rather than the problem itself. It doesn't help solve the problem

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by jsulm
                                  #16

                                  @canid Your refusal to provide your code, so others can look into it to find the issue, doesn't help either.
                                  As you apparently don't want to simply post your code instead of making an endless and useless discussion I will retract from this thread...

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  4
                                  • K Offline
                                    K Offline
                                    kuzulis
                                    Qt Champions 2020
                                    wrote on last edited by
                                    #17

                                    @jsulm, @J-Hilk ,

                                    Guys, you made my day. For such patience, medals should be awarded. ))))

                                    1 Reply Last reply
                                    3
                                    • C canid

                                      @jsulm
                                      Please give an example to show that not uploading source code does not solve the problem.I have posted the main function code, how can you say there is no code

                                      JKSHJ Offline
                                      JKSHJ Offline
                                      JKSH
                                      Moderators
                                      wrote on last edited by JKSH
                                      #18

                                      @canid said in Why console prompt: QEventLoop: Cannot be used without QApplication?:

                                      Please give an example to show that not uploading source code does not solve the problem.

                                      • https://forum.qt.io/topic/72184/hide-show-a-widget/
                                      • https://forum.qt.io/topic/94199/letting-the-user-set-the-respective-directory-within-a-qt-wigdet-application
                                      • https://forum.qt.io/topic/104087/text-alignment

                                      After the asker provided code, the helper was able to see the problem in the code immediately. Thus, a solution was found very quickly.

                                      Pay extra attention to the "Text Alignment" example: Because the asker provided code in the original post, the helper was able to post the solution in the very first reply!

                                      I have posted the main function code

                                      Thank you for that. However, we still need more because the code that you posted cannot produce the "QEventLoop: Cannot be used without QApplication" message.

                                      That's why I said: Please copy + paste the actual code from your project. Then, we will be able to show you where to fix the problem.

                                      Note: We're not asking for code for fun. We're asking for code because the code will help us to help you.

                                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                      1 Reply Last reply
                                      4

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved