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

Qt application not responding

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 5.0k 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.
  • A Offline
    A Offline
    Adrian.Aioanei
    wrote on last edited by Adrian.Aioanei
    #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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      2
      • J Offline
        J Offline
        jsavin
        wrote on last edited by
        #3

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

        qApp->processEvents();
        

        Give it a try !

        jsulmJ 1 Reply Last reply
        1
        • J jsavin

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

          qApp->processEvents();
          

          Give it a try !

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on 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
          • mrjjM mrjj

            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 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.

            jsulmJ 1 Reply Last reply
            0
            • A Adrian.Aioanei

              @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.

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on 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 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.

                jsulmJ 1 Reply Last reply
                0
                • A Adrian.Aioanei

                  @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.

                  jsulmJ Online
                  jsulmJ Online
                  jsulm
                  Lifetime Qt Champion
                  wrote on 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 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

                    • Login

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