I am currently developing a PyQt application in Visual Studio. Debugging has been working great, until I decided to keep my UI responsive by moving stuff to a worker thread with Qt Threads.
class MainWindow(base, form):
start_work = QtCore.pyqtSignal()
def __init__(self, parent=None):
# Create a seperate thread in which the update information is polled.
self.thread = QtCore.QThread()
# Create Worker object and move it to new thread
self.worker = Worker()
self.worker.moveToThread(self.thread)
# connect signal to start work in the extra tread
self.start_work.connect(self.worker.get_work_done)
self.thread.start()
#function emit a signal to start doing the work
def do_work(self):
self.startWork.emit()
Any function that is invoked on my worker object is connected via signal slots
class Worker(QtCore.QObject):
@QtCore.pyqtSlot()
def get_work_done(self):
#lets do some time consuming work.
The code works fine. The only problem is now, I cannot debug anything that is happening inside get_work_done
. Visual studio won't break at those breakpoints.
When I break inside any MainWindow
function, the Visual Studio Debugger shows only one thread. It seems unaware of any other threads created by the application.