I am in the process up upgrading my code from Qt4.7 w/ VS2008 to Qt5 w/ VS2012. The very last compile error I am getting is with regards to checking which custom button was clicked on a QMessageBox. Here is the code:
QPushButton *renameButton = msgBox.addButton(tr("Rename"), QMessageBox::ActionRole);
QPushButton *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::DestructiveRole);
msgBox.addButton(QMessageBox::Cancel);
msgBox.exec();
if( msgBox.clickedButton() == deleteButton)
{
}
The issue is in the final if statement, I get the error:
error C2440: ‘==’ : cannot convert from ‘QPushButton *’ to ‘QAbstractButton *’
I have tried qobject_casting the clickedButton to a QPushButton:
QPushButton *clickedButton = qobject_cast<QPushButton *>(msgBox.clickedButton());
But I get this error:
‘qobject_cast’ : none of the 2 overloads could convert all the argument types
Any suggestions on how to fix this?
↧