Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
99 views
in Technique[技术] by (71.8m points)

python - QThread and data coming from main window

I have a main window created with PyQt5, i.e.:

class PrincipalClass(QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_PrincipalForm()
        self.ui.setupUi(self)
        self.list = []
        self.filename = ""
        self.chars = ""
        self.filename_noext = ""

I have also a function inside the class:

def checkchars(self):
    self.chars = ""
    if self.ui.minuscoleCb.isChecked():
        self.chars += self.minuscole
    if self.ui.maiuscoleCb.isChecked():
        self.chars += self.maiuscole
    if self.ui.numeriCb.isChecked():
        self.chars += self.numeri
   

Now I want to create a QThread class with his run function that I want to use in order to do some calculations, but I need to use inside the QThread class the result of self.chars coming from the main window.

class External(QThread):
    
    word = pyqtSignal(str)

    def run(self):

How can I have the value of self.chars available inside the QThread class? I know that from QThread to main window I can use the signal way, but viceversa?

question from:https://stackoverflow.com/questions/65924992/qthread-and-data-coming-from-main-window

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...