I have two QActions in a right-click menu. I'm trying to check one action and show a tick next to it. While positive is checked and if I check positive a second time, it should return the program to the default mode and remove the tick. If negative is checked after positive, the tick should move to negative. I revised similar questions but I could not figure it out. I'll be grateful for your help.
void MainInterfaceWindow::ShowContextMenu(const QPoint &pos)
{
QMenu contextMenu(tr("Context menu"), this);
QAction action1("Positive", this);
QAction action2("Negative", this);
contextMenu.addAction(&action1);
contextMenu.addAction(&action2);
connect(&action1, SIGNAL(triggered()), this, SLOT(positiveSlope()));
connect(&action2, SIGNAL(triggered()), this, SLOT(negativeSlope()));
m_mouseLocation=pos;
contextMenu.exec(mapToGlobal(pos));
}
void MainInterfaceWindow::positiveSlope()
{
ui->openGLWidget->m_positive_slope=true;
ui->openGLWidget->m_negative_slope=false;
}
void MainInterfaceWindow::negativeSlope()
{
ui->openGLWidget->m_negative_slope=true;
ui->openGLWidget->m_positive_slope=false;
}