Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Thread.started signal - can it be edited to pass a variable?

Thread.started signal - can it be edited to pass a variable?

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 3 Posters 311 Views
  • 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.
  • I Offline
    I Offline
    Igor86
    wrote on last edited by
    #1

    Hello,

    i used the signal the thread emits when it started to connect it to a function like this:

        self.thread.started.connect(self.worker.run)
    

    now, i would need to pass a variable to run(). its my understanding that this should be done with the signal, but started is a preexisting signal. How am I supposed to do this?

    is there a way to edit/overwrite the started signal?
    should this started signal start a intermediate function that starts a new signal that has the structure I need?

    what is the proper way of doing it?

    Thank you!

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • I Igor86

      Hello,

      i used the signal the thread emits when it started to connect it to a function like this:

          self.thread.started.connect(self.worker.run)
      

      now, i would need to pass a variable to run(). its my understanding that this should be done with the signal, but started is a preexisting signal. How am I supposed to do this?

      is there a way to edit/overwrite the started signal?
      should this started signal start a intermediate function that starts a new signal that has the structure I need?

      what is the proper way of doing it?

      Thank you!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Igor86 said in Thread.started signal - can it be edited to pass a variable?:

      i would need to pass a variable to run()

      Why?
      You can pass that variable before starting thread (either as constructor parameter or a getter method).

      If you really need to pass a parameter to run use a lambda.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      I 1 Reply Last reply
      1
      • I Igor86

        Hello,

        i used the signal the thread emits when it started to connect it to a function like this:

            self.thread.started.connect(self.worker.run)
        

        now, i would need to pass a variable to run(). its my understanding that this should be done with the signal, but started is a preexisting signal. How am I supposed to do this?

        is there a way to edit/overwrite the started signal?
        should this started signal start a intermediate function that starts a new signal that has the structure I need?

        what is the proper way of doing it?

        Thank you!

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @Igor86 is that run supposed to be the override run method of the QThread base class ?

        because that can not have arguments or its not the overridden base class method, that runs in a different thread from the main one


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @Igor86 said in Thread.started signal - can it be edited to pass a variable?:

          i would need to pass a variable to run()

          Why?
          You can pass that variable before starting thread (either as constructor parameter or a getter method).

          If you really need to pass a parameter to run use a lambda.

          I Offline
          I Offline
          Igor86
          wrote on last edited by
          #4

          @jsulm said in Thread.started signal - can it be edited to pass a variable?:

          @Igor86 said in Thread.started signal - can it be edited to pass a variable?:

          i would need to pass a variable to run()

          Why?
          You can pass that variable before starting thread (either as constructor parameter or a getter method).

          If you really need to pass a parameter to run use a lambda.

          uoooohhhh thank you! didnt know I can pass values before i start the thread.. this is a gamechanger..

          thank you very much!

          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