Results 1 to 3 of 3

Thread: Error on casting QMessageBox::StandardButton to pass a value to function

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Error on casting QMessageBox::StandardButton to pass a value to function

    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 ?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Error on casting QMessageBox::StandardButton to pass a value to function

    you need to pass QMessageBox::StandardButtons and not QMessageBox::StandardButton

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Error on casting QMessageBox::StandardButton to pass a value to function

    Yes, right !
    Thank you very much

Similar Threads

  1. Replies: 14
    Last Post: 1st December 2009, 20:45
  2. Mouse Freezes upon using QmessageBox::warning function.
    By kaushal_gaurav in forum Qt Programming
    Replies: 4
    Last Post: 18th June 2008, 05:50
  3. How to pass a QComboBox to a function?
    By Ricardo_arg in forum General Programming
    Replies: 4
    Last Post: 9th March 2008, 22:16
  4. QHBoxLayout and QMessageBox error
    By zorro68 in forum Qt Programming
    Replies: 12
    Last Post: 7th February 2008, 10:57
  5. QMessageBox error
    By Salazaar in forum Newbie
    Replies: 4
    Last Post: 11th June 2007, 20:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.