Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZMessageBox Class Reference

Displays a brief message, an icon, and some buttons. More...

#include <ZMessageBox.h>

Inheritance diagram for ZMessageBox::

ZBaseDialog QDialog List of all members.

Public Methods

 ZMessageBox (QWidget *parent, const QPixmap &iconPixmap, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int modal=ZBaseDialog::APP_MODAL)
 Constructor for a message box with a text, an icon and up to three buttons. More...

 ZMessageBox (QWidget *parent, const QPixmap &iconPixmap, const QString &text, const int nseconds, int modal=ZBaseDialog::APP_MODAL)
 Constructor for a message box with a text, an icon. More...

 ~ZMessageBox ()
 Destructor. More...

void setText (const QString &text)
 Sets the message box text to be displayed. More...

void setIconPixmap (const QPixmap &pixmap)
 Sets the message box icon to be displayed. More...

void setButtonText (int button, const QString &text)
 Sets the text of the message box button. More...

void adjustSize ()
 Adjusts the size of the message box to fit the contents just before QDialog::exec() or QDialog::show() is called. More...


Static Public Methods

int information (QWidget *parent, const QPixmap &iconPixmap, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int modal=ZBaseDialog::APP_MODAL)
 Opens an message box with a text and up to three buttons. More...

int timerInformation (QWidget *parent, const QPixmap &iconPixmap, const QString &text, int nseconds, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int modal=ZBaseDialog::APP_MODAL)
 Opens an information message box with a text and up to threee buttons. More...

void timerMessage (QWidget *parent, const QPixmap &iconPixmap, const QString &text, const int nseconds, int modal=ZBaseDialog::APP_MODAL)
 Opens an information message box with a text and no button. More...


Protected Methods

void resizeEvent (QResizeEvent *)
 @reimplemented. More...

void keyPressEvent (QKeyEvent *)
 @reimplemented. More...


Detailed Description

Displays a brief message, an icon, and some buttons.

ZMessageBox provides two types of dialogs: a dialog with up to three buttons and a dialog which will automatically disappear after specified seconds.

As ZMessageBox inherits from ZBaseDialog, the ZMessageBox modal can be modeless, modal, and system modal.

See also:
ZBaseDialog

For the message box with buttons, the class takes care of the buttons' geometry management. The return value of exec function is the button index which was clicked. For example, if the leftmost button was clicked, return valus is 0.

  ZMessageBox* msgbox = new ZMessageBox(this, pixmapPhone,
                            "System Failure\nUnleashing fury upon the world now....",
                            "OK",
                            "Cancel",
                            NULL
                            );
  int reply = msgbox->exec();

  delete msgbox;
 
  switch(reply)
  {
    case 0:
        cout<<"OK was Pressed"<<endl;
        break;
    case 1:
        cout<<"Cancel was Pressed"<<endl;
        break;
  }

Below is the example of a message box which will automitically disappear after 2 seconds.

  ZMessageBox* msgbox = new ZMessageBox(this, pixmapPhone,
                            "System Failure\nFormatting Disk C:",
                             2);
  msgbox->exec();
  delete msgbox;


Constructor & Destructor Documentation

ZMessageBox::ZMessageBox ( QWidget * parent,
const QPixmap & iconPixmap,
const QString & text,
const QString & button0Text = QString::null,
const QString & button1Text = QString::null,
const QString & button2Text = QString::null,
int modal = ZBaseDialog::APP_MODAL )
 

Constructor for a message box with a text, an icon and up to three buttons.

Parameters:
parent   The parent object of this widget.
iconPixmap   Icon shown on the dialog.
text   Content text on the dialog
button0Text   the leftmost button text
button1Text   the middle button text
button2Text   the rightmost button text
modal   the modal of the message box

ZMessageBox::ZMessageBox ( QWidget * parent,
const QPixmap & iconPixmap,
const QString & text,
const int nseconds,
int modal = ZBaseDialog::APP_MODAL )
 

Constructor for a message box with a text, an icon.

The message box will automatically disappear after nseconds.

Parameters:
parent   The parent object of this widget.
iconPixmap   Icon shown on the dialog
text   Content text on the dialog
nseconds   Seconds the dialog will disappear
modal   The modal of the dialog

ZMessageBox::~ZMessageBox ( )
 

Destructor.


Member Function Documentation

void ZMessageBox::adjustSize ( )
 

Adjusts the size of the message box to fit the contents just before QDialog::exec() or QDialog::show() is called.

int ZMessageBox::information ( QWidget * parent,
const QPixmap & iconPixmap,
const QString & text,
const QString & button0Text = QString::null,
const QString & button1Text = QString::null,
const QString & button2Text = QString::null,
int modal = ZBaseDialog::APP_MODAL ) [static]
 

Opens an message box with a text and up to three buttons.

Parameters:
parent   The parent object of this widget
iconPixmap   the icon on the message box
text   the content text on the message box
button0Text   the leftmost button text
button1Text   the middle button text
button2Text   the rightmost button text
modal   the modal of the message box

Returns:
the identifier of the button that was clicked.

void ZMessageBox::keyPressEvent ( QKeyEvent * ) [protected]
 

@reimplemented.

void ZMessageBox::resizeEvent ( QResizeEvent * ) [protected]
 

@reimplemented.

void ZMessageBox::setButtonText ( int button,
const QString & text )
 

Sets the text of the message box button.

Parameters:
button   the button index, begin from 0.
text   the string will be shown on the button.

void ZMessageBox::setIconPixmap ( const QPixmap & pixmap )
 

Sets the message box icon to be displayed.

Parameters:
pixmap   the icon will be shown.

void ZMessageBox::setText ( const QString & text )
 

Sets the message box text to be displayed.

Parameters:
text   the string will be shown

int ZMessageBox::timerInformation ( QWidget * parent,
const QPixmap & iconPixmap,
const QString & text,
int nseconds,
const QString & button0Text = QString::null,
const QString & button1Text = QString::null,
const QString & button2Text = QString::null,
int modal = ZBaseDialog::APP_MODAL ) [static]
 

Opens an information message box with a text and up to threee buttons.

The message box will return if timer is set.

Parameters:
parent   the parent of the message box
iconPixmap   the icon on the message box
text   the content text on the message box
nseconds   the seconds the message box will time out
button0Text   the leftmost button text
button1Text   the middle button text
button2Text   the rightmost button text
modal   the modal of the message box

Returns:
the identifier of the button that was clicked. If timer is set, when the time timeout, the return value is -1.

void ZMessageBox::timerMessage ( QWidget * parent,
const QPixmap & iconPixmap,
const QString & text,
const int nseconds,
int modal = ZBaseDialog::APP_MODAL ) [static]
 

Opens an information message box with a text and no button.

The message box will return if timer is set.

Parameters:
parent   the parent of the message box
iconPixmap   the icon on the message box
text   the content text on the message box
nseconds   the seconds the message box will time out
modal   the modal of the message box


The documentation for this class was generated from the following file:
Generated at Wed Mar 3 13:22:59 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001