QMessageBox Class Reference


The QMessageBox widget provides a message box. More...

#include <qmsgbox.h>

Inherits QDialog.

List of all member functions.

Public Members

Static Public Members

Protected Members


Detailed Description

The QMessageBox widget provides a message box.

A message box is a dialog that displays a text and a push button.

The default push button text is "Ok". This can be changed with setButtonText().

Enabling auto-resizing will make a message box resize itself whenever the contents change.

Example of use:

    QMessageBox mb;
    mb.setText( "This program may crash your hardware!!!\nLet's start..." );
    mb.setButtonText( "Yes!" );
    mb.show();

Member Function Documentation

QMessageBox::QMessageBox ( QWidget *parent=0, const char *name=0)

Constructs a message box with no text and a button with the text "Ok".

If parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

The parent and name arguments are passed to the QDialog constructor.

void QMessageBox::adjustSize () [virtual]

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

This function will not be called if the message box has been explicitly resized before showing it.

Reimplemented from QWidget.

const char * QMessageBox::buttonText () const

Returns the push button text currently set, or null if no text has been set.

See also: setButtonText().

int QMessageBox::message ( const char *caption, const char *text, const char *buttonText=0, QWidget *parent=0, const char *name=0) [static]

Opens a modal message box directly using the specified parameters.

Example:

    QMessageBox::message( "Warning", "Did you feed the giraffe?", "Sorry!" );

Examples: widgets/widgets.cpp

bool QMessageBox::query ( const char *caption, const char *text, const char *yesButtonText=0, const char *noButtonText=0, QWidget *parent=0, const char *name=0) [static]

Queries the user using a modal message box with two buttons. Note that caption is not always shown, it depends on the window manager.

text is the question the user is to answer. yesButtonText defaults to "Yes" and noButtonText defaults to "No".

Example:

    bool ok = QMessageBox::query( "Consider this carefully", 
                             "Should I delete all your files?", 
                             "Go ahead!", "Wait a minute" );
    if ( ok )
        deleteAllFiles();

void QMessageBox::resizeEvent ( QResizeEvent *) [virtual protected]

Internal geometry management.

Reimplemented from QWidget.

void QMessageBox::setButtonText ( const char *text)

Sets the push button text to be displayed.

The default push button text is "Ok".

See also: buttonText().

void QMessageBox::setText ( const char *text)

Sets the message box text to be displayed.

See also: text().

const char * QMessageBox::text () const

Returns the message box text currently set, or null if no text has been set.

See also: setText().


This file is part of the Qt toolkit, copyright © 1995-97 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 17:29, 1997/04/07 for Qt version 1.2 by the webmaster at Troll Tech