Task: place the drop down menu.
There is a QMenuBar, and it is clear to him: I declare him, attached to him QMenu, to the QAction and drop down menu ready.
There is a QToolBar, and it's not clear at all. QAction strengthen learned, and menu no. Opened the documentation
carefully and tried to understand — the whole day was spent on it. To no avail.
Here is the code:
toolBar = QToolBar() #Ubavlyaem toolbar
self.addToolBar(toolBar) #Fasten it to the window
Button=QToolButton(self) #Declare a button that should contain a drop-down menu
Button.setIcon(QIcon(self.style().standardIcon(QStyle.SP_TitleBarMaxButton))) #give it an icon
settingsMenu=QMenu()#Create the menu that will appear
action1 = settingsMenu.addAction("Item 1") #Add item меню1
settingsMenu.addSeparator() #a Separator, to make it prettier :)
action2= settingsMenu.addAction("Пункт2")#Add item меню2
action3= settingsMenu.addAction("Item 3")#Add item меню3
Button.setMenu(settingsMenu) #Touches to the menu button
Button.setPopupMode(QToolButton.MenuButtonPopup) #Set mod for otobrany menu when you click
self.settingsButton = toolBar.addWidget(Button)#Add the resulting widget вToolBar
And all would be well, but in the end I just get absolutely beautiful button that shows absolutely nothing.
I think I spent the whole day walking around, but still can not extract the couple of lines that "do everything well".
Please help: how to declare drop down menu in a QToolBar? :(