^NyAw^
17th May 2007, 10:53
Hi,
I have a class inherited from QLineEdit and I want to show a custom context Menu.
MyLineEdit::MyLineEdit(QWidget *parent) : QLineEdit(parent)
{
ui.setupUi(this);
this->setContextMenuPolicy(Qt::CustomContextMenu);
}
void MyLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
//Never enters here
QMenu* pqMenu = new QMenu();
pqMenu->addAction(tr("Firts"));
pqMenu->addAction(tr("Second"));
pqMenu->exec(event->globalPos());
delete (pqMenu);
}
In the header file I have:
protected:
void contextMenuEvent(QContextMenuEvent *event);
Anyone knows what is the problem?
Thanks,
I have a class inherited from QLineEdit and I want to show a custom context Menu.
MyLineEdit::MyLineEdit(QWidget *parent) : QLineEdit(parent)
{
ui.setupUi(this);
this->setContextMenuPolicy(Qt::CustomContextMenu);
}
void MyLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
//Never enters here
QMenu* pqMenu = new QMenu();
pqMenu->addAction(tr("Firts"));
pqMenu->addAction(tr("Second"));
pqMenu->exec(event->globalPos());
delete (pqMenu);
}
In the header file I have:
protected:
void contextMenuEvent(QContextMenuEvent *event);
Anyone knows what is the problem?
Thanks,