<p>I have a few combo-boxes and  double spin boxes on my Qt Dialog. Now I need a "ResetToDefault" item on a menu that comes up when you right click on the widget (spin box or combo box).</p>

<p>How do i get it. Is there some way I can have a custom menu that comes up on right click or Is there a way i can add items to the menu that comes on right click.</p>

First, for Qt4, the simplest way is to create an action to reset the data, and add it the the widget using the
```
addAction
```
method (or use the designer). Then, set the
```
contextMenuPolicy
```
attribute to
```
Qt::ActionsContextMenu
```
. The context menu will appear and the action will be triggered.
Code example:
```
```
QAction *reset_act = new QAction("Reset to default");
mywidget->addAction(reset_act);
mywidget->setContextMenuPolicy(Qt::ActionsContextMenu);
// here connect the 'triggered' signal to some slot
```
```
For Qt3, you might have to intercept the context menu event, and thus inherit the QSpinBox and others. Or maybe you can intercept the context menu event from the main window, detect if it occurred above the widget supposed to have a context menu (using the
```
QWidget::childAt
```
method) and show it there. But you'll have to test.