Can you implement dialogs on different threads?
-
wrote on 9 Apr 2021, 07:43 last edited by
Hi, I have two dialogs which one is a sender dialog and the other is a receiver dialog. I wish to implement them on different threads but I'm not sure how to do it. From what I learn, thread can only be implemented on a QObject but not QDialog. Is there any suggestion on how to do so?
-
@mrjj Hi, thank you for your reply. Yes, I fully understand your point so that is the reason why I get stuck here. What I want to simulate is two different computers which one is sending signal (Sender) and the other is receiving signal (Receiver). So, obviously they are supposed to run on two different threads. But, since I create them as dialogs, I could not put them on threads apart from main thread. To implement my idea, is it that I should create QObject class and instantiate the dialog as a member of it?
Lifetime Qt Championwrote on 9 Apr 2021, 10:00 last edited by mrjj 4 Sept 2021, 10:01Hi
Running something in a thread in the same app, it's not like 2 computers much.You could run same app twice ? and talk between them ?
But that you wont use signals for.
So what is the task / assignment ?
you can run a qobject in other thread and talk to it from main.
see different samples here
https://github.com/DeiVadder/QtThreadExample -
Lifetime Qt Championwrote on 9 Apr 2021, 07:57 last edited by mrjj 4 Sept 2021, 07:58
Hi
Only the main thread can use QWidgets.
So a dialog cannot live in another thread in any way.But why did you want that in the first place ?
Maybe the goal can be reached in other ways.
Often one will run heavy code in its own thread. and then use signals to send info back to the
main thread / the GUI. -
Hi
Only the main thread can use QWidgets.
So a dialog cannot live in another thread in any way.But why did you want that in the first place ?
Maybe the goal can be reached in other ways.
Often one will run heavy code in its own thread. and then use signals to send info back to the
main thread / the GUI.wrote on 9 Apr 2021, 09:55 last edited by@mrjj Hi, thank you for your reply. Yes, I fully understand your point so that is the reason why I get stuck here. What I want to simulate is two different computers which one is sending signal (Sender) and the other is receiving signal (Receiver). So, obviously they are supposed to run on two different threads. But, since I create them as dialogs, I could not put them on threads apart from main thread. To implement my idea, is it that I should create QObject class and instantiate the dialog as a member of it?
-
@mrjj Hi, thank you for your reply. Yes, I fully understand your point so that is the reason why I get stuck here. What I want to simulate is two different computers which one is sending signal (Sender) and the other is receiving signal (Receiver). So, obviously they are supposed to run on two different threads. But, since I create them as dialogs, I could not put them on threads apart from main thread. To implement my idea, is it that I should create QObject class and instantiate the dialog as a member of it?
Lifetime Qt Championwrote on 9 Apr 2021, 10:00 last edited by mrjj 4 Sept 2021, 10:01Hi
Running something in a thread in the same app, it's not like 2 computers much.You could run same app twice ? and talk between them ?
But that you wont use signals for.
So what is the task / assignment ?
you can run a qobject in other thread and talk to it from main.
see different samples here
https://github.com/DeiVadder/QtThreadExample -
wrote on 11 Apr 2021, 00:08 last edited by
Thank you! The website clears things up for me :)
1/5