unice
unice

Reputation: 2842

dropdown menu with sub menu in pyqt4

how to create a drop down menu with sub menus that can execute an action when the element is selected? The data of the menu's are loaded from dictionary. I've tried the menu in qpushbutton but i think there's no sub menus for it. Here is an example of what i want to do, I only want the sub menus, but its too complicated for me. QPlainTextEdit With In Line Spell Check

Upvotes: 3

Views: 4825

Answers (1)

utdemir
utdemir

Reputation: 27256

You didn't say what did you do, but here's a simple example:

from PyQt4 import QtGui

app = QtGui.QApplication([])

menu = QtGui.QMenu()

sub_menu = QtGui.QMenu("Sub Menu")

for i in ["a", "b", "c"]: #or your dict
    sub_menu.addAction(i) #it is just a regular QMenu

menu.addMenu(sub_menu)

menu.show()

app.exec_()

Upvotes: 3

Related Questions