Macok
4th March 2009, 15:49
I'd like to add context menus for widgets on my form.
As I know to do that I should reimplement Widget::contextMenuEvent(QContextMenuEvent*) function.
But how can I reimplement it if widget is created in Qt Creator (designer)?
@EDIT
Ok, I found out I can do it by this way:
void QLineEdit::contextMenuEvent ( QContextMenuEvent * event ){
QMenu *menu=new QMenu;
(...)
menu->exec(event->globalPos());
}But is there any way to set context menu for only one lineedit?
As I know to do that I should reimplement Widget::contextMenuEvent(QContextMenuEvent*) function.
But how can I reimplement it if widget is created in Qt Creator (designer)?
@EDIT
Ok, I found out I can do it by this way:
void QLineEdit::contextMenuEvent ( QContextMenuEvent * event ){
QMenu *menu=new QMenu;
(...)
menu->exec(event->globalPos());
}But is there any way to set context menu for only one lineedit?