aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <[email protected]>2023-06-16 15:25:31 +0200
committerEdward Welbourne <[email protected]>2023-07-17 12:08:26 +0200
commitaf9daf4a2ab4684036de9ba56671b08aafaaf61d (patch)
tree4a26bf6da318059b64b24ac690756a9654eb3e9e
parente462727a3ef742f49dcba145714cf20d0b614ffb (diff)
DOM XBEL example: Combine create_actions() into create_menus()
This is to match the C++; the MainWindow doesn't need the QAction instances as member variables, they can perfectly well be simply created and used in the course of hooking them up to menus. Task-number: QTBUG-111228 Pick-to: 6.5 Change-Id: Ic6b936e4b6ccfd57ba22a7c738c36089547cf764 Reviewed-by: Shyamnath Premnadh <[email protected]>
-rw-r--r--examples/xml/dombookmarks/dombookmarks.py31
1 files changed, 10 insertions, 21 deletions
diff --git a/examples/xml/dombookmarks/dombookmarks.py b/examples/xml/dombookmarks/dombookmarks.py
index e77adc3d1..4fbc843e1 100644
--- a/examples/xml/dombookmarks/dombookmarks.py
+++ b/examples/xml/dombookmarks/dombookmarks.py
@@ -21,7 +21,6 @@ class MainWindow(QMainWindow):
self._xbel_tree = XbelTree()
self.setCentralWidget(self._xbel_tree)
- self.create_actions()
self.create_menus()
self.statusBar().showMessage("Ready")
@@ -70,32 +69,22 @@ class MainWindow(QMainWindow):
"The <b>DOM Bookmarks</b> example demonstrates how to use Qt's "
"DOM classes to read and write XML documents.")
- def create_actions(self):
- self._open_act = QAction("&Open...", self, shortcut="Ctrl+O",
- triggered=self.open)
-
- self._save_as_act = QAction("&Save As...", self, shortcut="Ctrl+S",
- triggered=self.save_as)
-
- self._exit_act = QAction("E&xit", self, shortcut="Ctrl+Q",
- triggered=self.close)
-
- self._about_act = QAction("&About", self, triggered=self.about)
-
- self._about_qt_act = QAction("About &Qt", self,
- triggered=qApp.aboutQt)
-
def create_menus(self):
self._file_menu = self.menuBar().addMenu("&File")
- self._file_menu.addAction(self._open_act)
- self._file_menu.addAction(self._save_as_act)
- self._file_menu.addAction(self._exit_act)
+ self._file_menu.addAction(QAction("&Open...", self,
+ shortcut=QKeySequence(Qt.CTRL | Qt.Key_O), triggered=self.open))
+ self._file_menu.addAction(QAction("&Save As...", self,
+ shortcut=QKeySequence(Qt.CTRL | Qt.Key_S), triggered=self.save_as))
+ self._file_menu.addAction(QAction("E&xit", self,
+ shortcut=QKeySequence(Qt.CTRL | Qt.Key_Q), triggered=self.close))
self.menuBar().addSeparator()
self._help_menu = self.menuBar().addMenu("&Help")
- self._help_menu.addAction(self._about_act)
- self._help_menu.addAction(self._about_qt_act)
+ self._help_menu.addAction(QAction("&About", self,
+ triggered=self.about))
+ self._help_menu.addAction(QAction("About &Qt", self,
+ triggered=qApp.aboutQt))
class XbelTree(QTreeWidget):