Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Can you implement dialogs on different threads?
Forum Updated to NodeBB v4.3 + New Features

Can you implement dialogs on different threads?

Scheduled Pinned Locked Moved Solved Qt 6
5 Posts 2 Posters 614 Views 1 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.
  • C Offline
    C Offline
    Christina123
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • C Christina123

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

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #4

      @Christina123

      Hi
      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

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #2

        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.

        C 1 Reply Last reply
        2
        • mrjjM mrjj

          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.

          C Offline
          C Offline
          Christina123
          wrote on last edited by
          #3

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

          mrjjM 1 Reply Last reply
          0
          • C Christina123

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

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #4

            @Christina123

            Hi
            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

            1 Reply Last reply
            3
            • C Offline
              C Offline
              Christina123
              wrote on last edited by
              #5

              Thank you! The website clears things up for me :)

              1 Reply Last reply
              0

              • Login

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