# Namespace KMessage

Module | kdecore
Namespace | KMessage

Display an informative message using a KMessageHandler.

This class does not define how to display a message, it is just a clean interface for developers to use. The job is done by the current KMessageHandler set in the class.

If no KMessageHandler is currently registered in KMessage, the message will be outputed to stderr.

Use KMessage.setMessageHandler() to use a KMessageHandler.

    KMessage.setMessageHandler( new KMessageBoxHandler(this) );
    // some operation

    KMessage.message( KMessage.Error, i18n("Could not load service. Use kbuildsycoca to fix the service database."), i18n("KService") );

Some KMessageHandler are already done such as KMessageBoxMessageHandler and KPassivePopupMessageHandler. Author Michaël Larouche <michael.larouche@kdemail.net>

### enums

- MessageType { Error, Information, Warning, Sorry, Fatal }

enum details

### methods

- message (messageType, text, caption)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  messageType | KMessage.MessageType |
  text | QString |
  caption | QString | QString()

  Display a long message of a certain type. A long message span on multiple lines and can have a caption.

  messageType - Currrent type of message. See MessageType enum.

  text - Long message to be displayed.

  caption - Caption to be used. This is optional.

- setMessageHandler (handler)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  handler | KMessageHandler |

  Set the current KMessageHandler Note that this method take ownership of the KMessageHandler.

  handler - Instance of a real KMessageHandler.

  This function isn't thread-safe. You don't want to change the message handler during the program's execution anyways. Do so only at start-up.

### enums - detail

- MessageType { Error, Information, Warning, Sorry, Fatal }

  Error message. Display critical information that affect the behavior of the application.

  | Error | - | - | Error message. Display critical information that affect the behavior of the application.
  | Information | - | - |
  | Warning | - | - |
  | Sorry | - | - |
  | Fatal | - | - |