KMessage Namespace Reference


enum  MessageType {
  Error, Information, Warning, Sorry,


KCOREADDONS_EXPORT void message (KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
KCOREADDONS_EXPORT void setMessageHandler (KMessageHandler *handler)

Detailed Description

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.

MichaĆ«l Larouche micha[email protected]el.l[email protected]arouc[email protected][email protected][email protected]demai[email protected][email protected]t

Enumeration Type Documentation

◆ MessageType


Error message.

Display critical information that affect the behavior of the application.


Information message.

Display useful information to the user.


Warning message.

Display a message that could affect the behavior of the application.


Sorry message.

Display a message explaining that a task couldn't be accomplished.


Fatal message.

Display a message before the application fail and close itself.

Definition at line 40 of file kmessage.h.

Function Documentation

◆ message()

void KMessage::message ( KMessage::MessageType  messageType,
const QString text,
const QString caption = QString() 

Display a long message of a certain type.

A long message span on multiple lines and can have a caption.

messageTypeCurrrent type of message. See MessageType enum.
textLong message to be displayed.
captionCaption to be used. This is optional.

Definition at line 82 of file kmessage.cpp.

◆ setMessageHandler()

void KMessage::setMessageHandler ( KMessageHandler handler)

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

handlerInstance 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.

Definition at line 76 of file kmessage.cpp.

KCOREADDONS_EXPORT void setMessageHandler(KMessageHandler *handler)
Set the current KMessageHandler Note that this method takes ownership of the KMessageHandler.
Definition: kmessage.cpp:76
KCOREADDONS_EXPORT void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
Display a long message of a certain type.
Definition: kmessage.cpp:82
QString i18n(const char *text, const TYPE &arg...)
@ Error
Error message.
Definition: kmessage.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun May 22 2022 04:08:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.