QMessageBox Class Reference


The QMessageBox widget provides a modal message box. (details) (complete member list)

#include <qmsgbox.h>

Inherits QDialog.

Public Members

Static Public Members

Protected Members


Detailed Description

The QMessageBox widget provides a modal message box.

A message box is a modal view that displays a text and contains 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.exec();

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 real widget, the message box becomes modal relative to parent.

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

void QMessageBox::adjustSize ()

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.

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)

Opens a message box directly using the specified parameters.

Example of use:

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

void QMessageBox::resizeEvent (QResizeEvent *)

Internal geometry management.

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 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech