No, it has nothing at all to do with threads. Where did I mention threads? I mentioned state machine, didn't I?
and you can 'use' any widget you want in a thread, but you can only make widgets in the main thread.
No, it has nothing at all to do with threads. Where did I mention threads? I mentioned state machine, didn't I?
and you can 'use' any widget you want in a thread, but you can only make widgets in the main thread.
Last edited by amleto; 23rd December 2011 at 18:34.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Then what is this state machine for? If you do this in main Gui thread you don't need to remember current state, everything happens consecutively like in my last example of code.
your code has a problem when user keep pressing buttons. using a statemachine can resolve this problem. Is that the third time I have said it now?
Last edited by amleto; 23rd December 2011 at 21:09.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
You are still not explaining how state machine could solve this problem.
I think you are missing the fact that generation and delivery of QKeyEvent does not happen in background. There is no concurrency between construction of window and delivery of QKeyEvents. Here is the flow:
1. QKeyEvent is dispatched to MainWindow.
--- in the background user presses another two keys ---
2. keyPressedEvent constructs HelpDialog.
3. New event loop is started by calling exec() on modal dialog.
4. In the new loop Linux keyboard driver's output buffer is checked and two new keys are found. (actually I'm not sur how it happens, that's one of the things I'm trying to figure out).
5. Two QKeyEvent objects are generated for both of new keys.
6. The first is dispatched to HelpDialog which has focus now.
7. Later the second one will be dispatched to widget with focus (who knows which).
This is how it works (more or less) in my system.
Sorry, for some reason I have been thinking that you had a problem with too many events sent to the main window.
Anyway, your problem is purely down the event handler (or something else on the main thread) taking up too much time. It is blocking the main thread from handling events quickly, and that is why a key press on mainwindow is getting delayed and sent to another window.
Move heavy work out of the gui thread - it should not be there anyway.
Last edited by amleto; 24th December 2011 at 12:17.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Bookmarks