
Originally Posted by
wysota
Wait a moment, where did you put the code snippet you pasted in the first post?
Hi wysota,
The example is like this:
MainWindow::MainWindow()
{
...
createContextMenu()
connect(ui->textEdit,SIGNAL(customContextMenuRequest(const QPoint&)),this,SLOT(showContextMenu()));
...
}
void MainWindow::createContextMenu()
{
editContextMenu = ui->textEdit->createStandardContextMenu();
editContextMenu->addAction(clear);
ui->textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
}
void MainWindow::showContextMenu()
{
if(editContextMenu)
editContextMenu
->exec
(QCursor::pos());
}
MainWindow::MainWindow()
{
...
createContextMenu()
connect(ui->textEdit,SIGNAL(customContextMenuRequest(const QPoint&)),this,SLOT(showContextMenu()));
...
}
void MainWindow::createContextMenu()
{
editContextMenu = ui->textEdit->createStandardContextMenu();
editContextMenu->addAction(clear);
ui->textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
}
void MainWindow::showContextMenu()
{
if(editContextMenu)
editContextMenu ->exec(QCursor::pos());
}
To copy to clipboard, switch view to plain text mode
Thanks for your reply
Bookmarks