Programm crashes when textBrowser get's called from other class
So I'm building a GUI in pyqt.
I have a class Ui_MainWindow(object): where my textBrowser is in
I also have a stream class where a videocapture get's streamed and some object detection
I want that everytime an object gets detected that the label get's appended in the textBrowser
But everytime I call textBrowser in my second class the programm crashes.
Thx in advance
class Ui_MainWindow(object): def setupUi(self, MainWindow): ... self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget) self.textBrowser.setMinimumSize(QtCore.QSize(860, 640)) self.textBrowser.setObjectName("textBrowser") self.gridLayout.addWidget(self.textBrowser, 0, 1, 1, 1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter) ... class Stream(QThread): ... for i in objects: textBrowser.append(i)
Hi and welcome to devnet,
You are breaking the main rule: do not manipulate GUI element from any other thread than the GUI thread.
Hey thx for answer.
You have any idea how I can achieve it on another way?
You have to use the signal from the thread
for i in objects:
(not sure its excact python syntax ;)
and then in MainWindow or other class that has the browser
you connect this new signal to a slot and in that slot
new signal to a slot and in that slot
ok that sounds good. I'll try tha
Man thx a lot for your help! Really appreciate it