Python Forum

Full Version: Subwindow
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
is instantiating a subwindow in the main window considered a new thread?
cuz I'm getting warnings like:
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)
which I think is from a Qthread in the subwindow. This is thread is a worker thread, not GUI related tho

There are actually two worker threads in the subwindow and only one is working Idk why

I'll upload the files but it'll be difficult to run cuz it requires certain equipment to be connected. And IDK why it won't allow me to upload the ui files.
No. Making a subwindow does not start a new thread.

Please make a small example that demonstrates your problem and post the code.
(Oct-21-2021, 04:12 PM)deanhystad Wrote: [ -> ]No. Making a subwindow does not start a new thread.

Please make a small example that demonstrates your problem and post the code.

The structure of my work is like this:

#Main Window Class
class MainUI(QMainWindow):
    def __init__(self):
    def main(self):
        self.ui=uic.loadUi('Main_ui.ui',self)
#a pushbutton to start a new window
        self.pushButton.clicked.connect(self.StartSubUi)
    def StartSubUi(self):
#mainwindow is passed to the subwindow as 'self.parent_win'
        self.subwindow=SubUI(self)
        self.subwindow.show()
#These two funcs have to be here as the connection of the equipment is done here
    def Func1(self):
        ...
    def Func2(self):
        ...

#Sub Window Class
class SubUI(QMainWindow):
    def __init__(self,parent_win):
        self.parent_win=parent_win
    def main(self):
        self.ui=uic.loadUi('Sub_ui.ui',self)
#a pushbutton to start to worker threads
        self.pushButton.clicked.connect(self.StartWorkerThreads)
    def StartWorkerThreads(self):
        self.thread1=WThread1()
        self.thread2=WThread2()
        self.thread1.sig1.connect(self.parent_win.Func1)
        self.thread2.sig2.connect(self.parent_win.Func2)
        self.thread1.start()
        self.thread2.start()

#Worker Thread Classes:
class WThread1(QThread):
    sig1=pyqtsignal()
    def run(self):
        #monitor a folder for new file and change name of them
        self.sig1.emit()

class WThread2(QThread):
    sig2=pyqtsignal()
    def run(self):
        #monitor a file to see if it is changed by the equipment output
        self.sig2.emit()

if __name__=='__main__':
    app = QApplication(sys.argv)
    win=MainUI()
    win.show()
    sys.exit(app.exec_())
Also, since it warns about curser, I wonder if this has sth to do with that, my WThread1 is outputing texts in a QtextBrowser in the main window, and WThread2 is changing the text in a progressBar window created in the sub window .
You really need to make a short WORKING example the demonstrates the problem. What you provided is not helpful.
(Oct-21-2021, 08:51 PM)deanhystad Wrote: [ -> ]You really need to make a short WORKING example the demonstrates the problem. What you provided is not helpful.

I found the problem, I didn't read one of the lineedits, the thread was activated but the for loop was empty so.
Thank anyways

I still don't know where the warning is from tho