aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-06-16 15:25:31 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-07-17 10:56:13 +0000
commitbe5a4762313c82980810cb012e5fac6702db283c (patch)
tree6bf4552c39bc1ebcd3018dc6f04b69365c5a1f35
parentb0654916421cf503d5f59324fde30275d8849d2b (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 Change-Id: Ic6b936e4b6ccfd57ba22a7c738c36089547cf764 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit af9daf4a2ab4684036de9ba56671b08aafaaf61d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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):