Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Set widget style from a menu selection.

$
0
0
This code works for building the menu at startup. It creates a submenu for each style found.         styleNames = QStyleFactory.keys()         for style in styleNames:             self.actionStyle = QAction(self)             self.actionStyle.setObjectName("actionStyle")             self.menu_Styles.addAction(self.actionStyle)             self.menu_Preferences.addAction(self.menu_Styles.menuAction())             self.menubar.addAction(self.menu_File.menuAction())             self.menubar.addAction(self.menu_Preferences.menuAction())             self.actionStyle.setText(style)             self.actionStyle.triggered.connect(self.changeStyle)) This is the changeStyle function. The purpose is to change the widget style based on the menu selection.     def changeStyle(self, styleName):         QApplication.setStyle(QStyleFactory.create(styleName)) The menu gets created properly but I cannot figure out how to pass the styleName string to the function. I’ve done a similar thing with a combobox which allowed me to pass the string with self.combobox.activated[str].connect(self.changeStyle). Similar syntax with ‘triggered’ does not work. The app starts and the menu look great but when I select one of the menu options I get an error about the number of arguments. TypeError: changeStyle() takes exactly 2 arguments (1 given) I am open to suggestions, advice, or comments. Thanks in advance, Cheers,

Viewing all articles
Browse latest Browse all 13965

Latest Images

Trending Articles



Latest Images