I already have this function to retrieve the clicked QPushButton
object name:
void MainWindow::clickedBtnInfo()
{
QPushButton *btnSender = qobject_cast<QPushButton*>(sender()); // retrieve the button you have clicked
QString *clickedBtnName = btnSender->objectName(); // retrive the object name from the clicked button
qDebug() << clickedBtnName;
}
And I checked this website to implement the rightClicked
signal.
But I want to know what I can do to retrieve the QPushButton
object name which is right clicked.
Thanks.
An edit of how I implement the rightClicked
signal:
void MainWindow::onRightClicked()
{
qDebug() << "User right clicked me";
}
void MainWindow::mousePressEvent(QMouseEvent *e)
{
if(e->button() == Qt::RightButton) {
emit rightClicked();
}
}
And connect like this:
connect(this, SIGNAL(rightClicked()), this, SLOT(onRightClicked()));
Sorry for not explaining my question completely before. BTW, I am just very new to Qt, So hope to get some specifically explained answers.
Thanks a lot.