[SOLVED] compile error with QMessageBox::clickedButton() == QPushButton* in VS2012
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);
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?
Did you @#include <QPushButton>@ ?
WOW, that was it. Thank you.
You're welcome !
Don't forget to update the thread's title to solved so other forum users may know that a solution has been found :)