Context Menu Creation with ‪ Qt Designer(Qt Creator IDE)

Mohammad Sheykholeslam picture Mohammad Sheykholeslam · Apr 26, 2010 · Viewed 8.7k times · Source

How can i create a Context menu in Qt Designer (1.3)? Certainly I want to create it with out writing one line code!!

Answer

Jose F. Velez picture Jose F. Velez · May 12, 2013

You need two steps in Qt Designer and a few lines of code in the form constructor:

  • Set the contextMenuPolicy of your widget to the value ActionsContextMenu.

  • Create actions using the action editor tab.

  • For each action you created in Qt Designer, put a line such as the following in the form constructor: ui->yourwidget->addAction(ui->youraction);