PDA

View Full Version : Error on casting QMessageBox::StandardButton to pass a value to function



tonnot
30th September 2010, 09:17
I have a 'genericfunciotn that manage YesNo or YesNoCancel :

Msg_GenericYesNoCancel(string title,string msg,QMessageBox::StandardButton tipo_yesnocancel)
{
reply = QMessageBox::question(this , QMessageBox::tr(title.c_str()), QMessageBox::tr(msg.c_str()),tipo_yesnocancel);
....
Ok, I have another funtion:
Msg_YesNo(std::string title, std::string msg)
{
return Msg_GenericYesNoCancel(title,msg,(QMessageBox::Sta ndardButton)(QMessageBox::Yes | QMessageBox::No));
}
If I do not cast to QMessageBox::Yes | QMessageBox::No, compiler gives me 'invalid conversion from int to QMessageBox::StandarButton.
I do the cast, i get : 'invalid cast from type 'QFlags<QMessageBox::StandardButton>' to type 'QMessageBox::StandardButton'
Any idea ?

tbscope
30th September 2010, 09:31
you need to pass QMessageBox::StandardButtons and not QMessageBox::StandardButton

tonnot
30th September 2010, 09:57
Yes, right !
Thank you very much