Qt application not responding
-
wrote on 12 Oct 2017, 15:14 last edited by Adrian.Aioanei 10 Dec 2017, 15:14
-
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? -
wrote on 12 Oct 2017, 16:53 last edited by
I often use this line on a loop to keep my application alive :
qApp->processEvents();
Give it a try !
-
I often use this line on a loop to keep my application alive :
qApp->processEvents();
Give it a try !
@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.
-
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?wrote on 13 Oct 2017, 06:19 last edited by 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.
-
@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.
@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.
-
wrote on 13 Oct 2017, 06:57 last edited by
@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.
-
@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.
@Adrian.Aioanei qApp is a macro. Include qapplication header file.
See http://doc.qt.io/qt-5/qapplication.html -
wrote on 13 Oct 2017, 07:51 last edited by
Thanks @jsulm .
I have made some changes and now I run the entire loop in a new thread and works perfectly.
4/9