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. Programm crashes when textBrowser get's called from other class
Forum Updated to NodeBB v4.3 + New Features

Programm crashes when textBrowser get's called from other class

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 3 Posters 625 Views 2 Watching
  • 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.
  • L Offline
    L Offline
    levoxtrip
    wrote on last edited by
    #1

    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)
    
    
    1 Reply Last reply
    -1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You are breaking the main rule: do not manipulate GUI element from any other thread than the GUI thread.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • L Offline
        L Offline
        levoxtrip
        wrote on last edited by
        #3

        Hey thx for answer.
        You have any idea how I can achieve it on another way?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          You have to use the signal from the thread

          like
          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 do

          textBrowser.append(i)

          1 Reply Last reply
          2
          • L Offline
            L Offline
            levoxtrip
            wrote on last edited by
            #5

            @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

            1 Reply Last reply
            0
            • L Offline
              L Offline
              levoxtrip
              wrote on last edited by
              #6

              Man thx a lot for your help! Really appreciate it

              1 Reply Last reply
              2

              • Login

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