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. How to access UI elements inside Worker class?
QtWS25 Last Chance

How to access UI elements inside Worker class?

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 226 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.
  • Q Offline
    Q Offline
    qtDevOps
    wrote on last edited by
    #1

    I have UI class produced by pyuic, Parent class which inherits and do some stuff like updating text and so, worker class inside same file as the parent class which does some long running task.

    I need to access textbox from UI class inside of worker class. How can I achieve it?

    class UI():
        textbox
        other_ui_elements
        .......
    
    class parent(UI):
        textbox.setText(userInput)
        ..................
    
    class worker(QThread):
       run(self):
         for text in textbox:
         print(text)
    
    jsulmJ 1 Reply Last reply
    0
    • Q qtDevOps

      I have UI class produced by pyuic, Parent class which inherits and do some stuff like updating text and so, worker class inside same file as the parent class which does some long running task.

      I need to access textbox from UI class inside of worker class. How can I achieve it?

      class UI():
          textbox
          other_ui_elements
          .......
      
      class parent(UI):
          textbox.setText(userInput)
          ..................
      
      class worker(QThread):
         run(self):
           for text in textbox:
           print(text)
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @qtDevOps As I wrote in your other thread (https://forum.qt.io/topic/128306/how-to-pass-a-variable-to-a-worker-thread-in-pyqt/4): do not touch UI in other threads...

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

      1 Reply Last reply
      3

      • Login

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