In my scenario, I want to show the assembly code and some other states of each threads. I hope that they can own their Dock Widgets which hold the thread states.
Here is an example code generated by ChatGPT
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget, QTextBrowser, QDockWidget, QWidget, QVBoxLayout, QTextEdit
class ThreadView(QMainWindow):
def __init__(self, parent=None):
super(ThreadView, self).__init__(parent)
# Create the central text browser
self.textBrowser = QTextBrowser()
self.setCentralWidget(self.textBrowser)
# Create the left dock widget
self.dockWidgetLeft = QDockWidget("Source Code", self)
self.dockWidgetLeft.setAllowedAreas(Qt.LeftDockWidgetArea)
self.sourceCodeEdit = QTextEdit()
self.dockWidgetLeft.setWidget(self.sourceCodeEdit)
self.addDockWidget(Qt.LeftDockWidgetArea, self.dockWidgetLeft)
# Create the right dock widget
self.dockWidgetRight = QDockWidget("GPR Values", self)
self.dockWidgetRight.setAllowedAreas(Qt.RightDockWidgetArea)
self.gprValuesEdit = QTextEdit()
self.dockWidgetRight.setWidget(self.gprValuesEdit)
self.addDockWidget(Qt.RightDockWidgetArea, self.dockWidgetRight)
# Set initial text for demonstration
self.textBrowser.setPlainText("Assembly code")
self.sourceCodeEdit.setPlainText("Source code")
self.gprValuesEdit.setPlainText("GPR values")
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Thread State Viewer")
# Create a QTabWidget
self.tabWidget = QTabWidget()
self.setCentralWidget(self.tabWidget)
# Add tabs for each thread
for i in range(3): # Example for 3 threads
thread_view = ThreadView()
self.tabWidget.addTab(thread_view, f"Thread {i+1}")
if __name__ == "__main__":
app = QApplication(sys.argv)
main_window = MainWindow()
main_window.resize(800, 600)
main_window.show()
sys.exit(app.exec_())
It shows the possibility to add a QMainWindow (class ThreadView here) into another widget (QTabWidget here). However, I can’t find any way to create a QMainWindow so I can put it into a tab widget. Is it possible to do that in QtDesigner5?