Add context menu
This commit is contained in:
parent
56fdcd9114
commit
a2fba6034b
1 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide6.QtCore import Qt, QSize
|
from PySide6.QtCore import Qt, QSize
|
||||||
|
from PySide6.QtGui import QAction
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QApplication,
|
QApplication,
|
||||||
QLabel,
|
QLabel,
|
||||||
|
|
@ -8,7 +9,8 @@ from PySide6.QtWidgets import (
|
||||||
QMainWindow,
|
QMainWindow,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QWidget,
|
QWidget,
|
||||||
QPushButton
|
QPushButton,
|
||||||
|
QMenu
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -84,6 +86,13 @@ class leekMainWindow(QMainWindow):
|
||||||
button = "right"
|
button = "right"
|
||||||
self.mouse_label.setText("mouseDoubleClickEvent " + button)
|
self.mouse_label.setText("mouseDoubleClickEvent " + button)
|
||||||
|
|
||||||
|
def contextMenuEvent(self, e):
|
||||||
|
context_menu = QMenu(self)
|
||||||
|
context_menu.addAction(QAction("Action 1", self))
|
||||||
|
context_menu.addAction(QAction("Action 2", self))
|
||||||
|
context_menu.addAction(QAction("Action 3", self))
|
||||||
|
context_menu.exec(e.globalPos())
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# If you know you won't use command line arguments QApplication([]) works too.
|
# If you know you won't use command line arguments QApplication([]) works too.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue