Open pying-around opened 7 months ago
The alternate code is given as : class MainWindow(QMainWindow): def init(self): super().init() self.show()
self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.on_context_menu) def on_context_menu(self, pos): context = QMenu(self) context.addAction(QAction("test 1", self)) context.addAction(QAction("test 2", self)) context.addAction(QAction("test 3", self)) context.exec(self.mapToGlobal(pos))
however Qt.CustomContextMenu is not defined until QT is added to the import statement
from PySide6.QtGui import QAction, Qt
The alternate code is given as : class MainWindow(QMainWindow): def init(self): super().init() self.show()
however Qt.CustomContextMenu is not defined until QT is added to the import statement
from PySide6.QtGui import QAction, Qt