KMessage

KMessage Namespace Reference

Enumerations

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

Functions

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.

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

Enumeration Type Documentation

◆ MessageType

Enumerator
Error 

Error message.

Display critical information that affect the behavior of the application.

Information 

Information message.

Display useful information to the user.

Warning 

Warning message.

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

Sorry 

Sorry message.

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

Fatal 

Fatal message.

Display a message before the application fail and close itself.

Definition at line 42 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 title.

Parameters
messageTypeCurrrent type of message. See MessageType enum.
textLong message to be displayed.
titleTitle to be used. This is optional.
Deprecated:
Since 5.97. Use Qt logging or custom message handling.

Definition at line 84 of file kmessage.cpp.

◆ setMessageHandler()

void KMessage::setMessageHandler ( KMessageHandler handler)

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

Parameters
handlerInstance of a real KMessageHandler.
Warning
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.
Deprecated:
Since 5.97. Use Qt logging or custom message handling.

Definition at line 78 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:78
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:84
QString i18n(const char *text, const TYPE &arg...)
@ Error
Error message.
Definition: kmessage.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Mar 27 2023 04:15:35 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.