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.5k 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.
  • 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 Offline
        jsulmJ Offline
        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 Offline
            jsulmJ Offline
            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 Offline
                jsulmJ Offline
                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
                  • A Offline
                    A Offline
                    APSH
                    wrote 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
                    0
                    • A APSH

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