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. Qt application not responding
Forum Updated to NodeBB v4.3 + New Features

Qt application not responding

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 6 Posters 5.3k Views 2 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.
  • A Offline
    A Offline
    Adrian.Aioanei
    wrote on 12 Oct 2017, 15:14 last edited by Adrian.Aioanei 10 Dec 2017, 15:14
    #1

    Hey,

    I have created an application for network monitor using Qt and Winpcap.
    The application is running in while loop and after 5 sec from start appears in the title bar "application not responding". Here is an image.
    alt text

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 12 Oct 2017, 15:23 last edited by
      #2

      Hi
      Well if it stays in the loop, it will strangulate the event loop.
      Are you sure it leaves the while loop once in a while?

      A 1 Reply Last reply 13 Oct 2017, 06:19
      2
      • J Offline
        J Offline
        jsavin
        wrote on 12 Oct 2017, 16:53 last edited by
        #3

        I often use this line on a loop to keep my application alive :

        qApp->processEvents();
        

        Give it a try !

        J 1 Reply Last reply 13 Oct 2017, 04:39
        1
        • J jsavin
          12 Oct 2017, 16:53

          I often use this line on a loop to keep my application alive :

          qApp->processEvents();
          

          Give it a try !

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 13 Oct 2017, 04:39 last edited by
          #4

          @jsavin @Adrian-Aioanei

          qApp->processEvents();
          

          This is just a work around for bad design! You should not block the event loop in frameworks like Qt. If you do you should move long lasting operations into separate threads.

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

          1 Reply Last reply
          2
          • M mrjj
            12 Oct 2017, 15:23

            Hi
            Well if it stays in the loop, it will strangulate the event loop.
            Are you sure it leaves the while loop once in a while?

            A Offline
            A Offline
            Adrian.Aioanei
            wrote on 13 Oct 2017, 06:19 last edited by Adrian.Aioanei
            #5

            @mrjj said in Qt application not responding:

            Hi
            Well if it stays in the loop, it will strangulate the event loop.
            Are you sure it leaves the while loop once in a while?

            Yes @mrjj ...the last line packageUpdate::processPackage() is a function where i make a switch and depending on the package type are called other function like printICMP, printTCP, print UDP s.a.m.d. And again every function (printICMP, printTCP, print UDP) call other functions like printIPHeader, print EthernetHeade. In every function, I print a message with QDebug and messages are displayed.
            Also for each package, i print the output in a text file and it works...all data is in that file. The only problem is with the interface.

            [UPDATE 1] I also tried to run the while loop on a new thread and the result is the same.

            J 1 Reply Last reply 13 Oct 2017, 06:43
            0
            • A Adrian.Aioanei
              13 Oct 2017, 06:19

              @mrjj said in Qt application not responding:

              Hi
              Well if it stays in the loop, it will strangulate the event loop.
              Are you sure it leaves the while loop once in a while?

              Yes @mrjj ...the last line packageUpdate::processPackage() is a function where i make a switch and depending on the package type are called other function like printICMP, printTCP, print UDP s.a.m.d. And again every function (printICMP, printTCP, print UDP) call other functions like printIPHeader, print EthernetHeade. In every function, I print a message with QDebug and messages are displayed.
              Also for each package, i print the output in a text file and it works...all data is in that file. The only problem is with the interface.

              [UPDATE 1] I also tried to run the while loop on a new thread and the result is the same.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 13 Oct 2017, 06:43 last edited by jsulm
              #6

              @Adrian.Aioanei As @mrjj said you're blocking the event loop while you're in that while loop (all that prints will work as they don't depend on event loop but UI will not). To check whether this loop is the problem put

              qApp->processEvents();
              

              in your while loop as @jsavin suggested. If this helps you should think about moving this long lasting operation (the while loop) to a separate thread.

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

              1 Reply Last reply
              1
              • A Offline
                A Offline
                Adrian.Aioanei
                wrote on 13 Oct 2017, 06:57 last edited by
                #7

                @jsulm said in Qt application not responding:

                @Adrian.Aioanei As @mrjj said you're blocking the event loop while you're in that while loop (all that prints will work as they don't depend on event loop but UI will not). To check whether this loop is the problem put

                qApp->processEvents();
                

                in your while loop as @jsavin suggested. If this helps you should think about moving this long lasting operation (the while loop) to a separate thread.

                What type of object is qApp? In main the type is resolved but in my class doesn't know what type is qApp.

                J 1 Reply Last reply 13 Oct 2017, 07:03
                0
                • A Adrian.Aioanei
                  13 Oct 2017, 06:57

                  @jsulm said in Qt application not responding:

                  @Adrian.Aioanei As @mrjj said you're blocking the event loop while you're in that while loop (all that prints will work as they don't depend on event loop but UI will not). To check whether this loop is the problem put

                  qApp->processEvents();
                  

                  in your while loop as @jsavin suggested. If this helps you should think about moving this long lasting operation (the while loop) to a separate thread.

                  What type of object is qApp? In main the type is resolved but in my class doesn't know what type is qApp.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 13 Oct 2017, 07:03 last edited by
                  #8

                  @Adrian.Aioanei qApp is a macro. Include qapplication header file.
                  See http://doc.qt.io/qt-5/qapplication.html

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

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Adrian.Aioanei
                    wrote on 13 Oct 2017, 07:51 last edited by
                    #9

                    Thanks @jsulm .
                    I have made some changes and now I run the entire loop in a new thread and works perfectly.

                    1 Reply Last reply
                    2
                    • A Offline
                      A Offline
                      APSH
                      wrote 10 days ago last edited by
                      #10

                      How long does it typically take for the system to mark a Qt application as 'Not Responding'?

                      SGaistS 1 Reply Last reply 10 days ago
                      0
                      • A APSH
                        10 days ago

                        How long does it typically take for the system to mark a Qt application as 'Not Responding'?

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote 10 days ago last edited by
                        #11

                        @APSH hi,

                        This is highly OS dependent, you should check their respective documentation.
                        There's also different way of "not responding". Your UI might be frozen while your application might be processing something which is not the same as a deadlock.

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

                        1 Reply Last reply
                        2

                        • Login

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