PDA

View Full Version : Four Buttons in QMessageBox::warning ?



npc
25th April 2007, 11:52
Hi,

I am using Qt 3.3.7.

How to use four buttons in QMessageBox::warning ?

In the document I came to know "The dialog may have up to three buttons".
We cant use more than 3 buttons ? is there any way ?

Thanks,
npc

high_flyer
25th April 2007, 12:01
yes, you can subclass.

npc
25th April 2007, 12:06
Thanks,

Could you explain me how to do that ?

-npc-

high_flyer
25th April 2007, 12:43
do what?
Derive a class?
Am... this is basic C++.
Its not something some one can teach you on a forum thread...
This book (http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html) should be a good start.

At any rate here is the answer to you question:


class QMessageBoxEx : publick QMessageBox
{
//contructors, destructors
static StandardButton /*or a new enum if you define one*/ warning ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
}

StandardButton QMessageBoxEx::warning ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons, StandardButton defaultButton, StandardButton defaultButton )
{
//your implementation
}


or something similar