Unsolved 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? -
Hi
You have to use the signal from the threadlike
for i in objects:
emit AppendThis(i);(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
you dotextBrowser.append(i)
-
@mrjj said in Programm crashes when textBrowser get's called from other class:
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