Namespace KGlobal |
|
|
Internal Make the struct of the K_GLOBAL_STATIC anonymous. @endcond This macro makes it easy to use non-POD types as global statics. The object is created on first use and creation is threadsafe. The object is destructed on library unload or application exit. Be careful with calling other objects in the destructor of the class as you have to be sure that they (or objects they depend on) are not already destructed. TYPE - The type of the global static object. Do not add a *. NAME - The name of the function to get a pointer to the global static object. If you have code that might be called after the global object has been destroyed you can check for that using the isDestroyed() function. If needed (If the destructor of the global object calls other functions that depend on other global statics (e.g. KConfig.sync) your destructor has to be called before those global statics are destroyed. A Qt post routine does that.) you can also install a post routine (@ref qAddPostRoutine) to clean up the object using the destroy() method. If you registered a post routine and the object is destroyed because of a lib unload you have to call qRemovePostRoutine! Example: class A { public: ~A(); ... }; A common case for the need of deletion on lib unload/app shutdown are Singleton classes. Here's an example how to do it: class MySingletonPrivate; class EXPORT_MACRO MySingleton { friend class MySingletonPrivate; public: static MySingleton *self(); QString someFunction();in the .cpp file: // This class will be instantiated and referenced as a singleton in this example class MySingletonPrivate { public: QString foo; MySingleton instance; }; Instead of the above you can use also the following pattern (ignore the name of the namespace): namespace MySingleton { EXPORT_MACRO QString someFunction(); }in the .cpp file: class MySingletonPrivate { public: QString foo; }; Now code that wants to call someFunction() doesn't have to do MySingleton.self()->someFunction();anymore but instead: MySingleton.someFunction(); This is the same as K_GLOBAL_STATIC, but can take arguments that are passed to the object's constructor TYPE - The type of the global static object. Do not add a *. NAME - The name of the function to get a pointer to the global static object. ARGS - the list of arguments, between brackets Example: class A { public: A(const char *s, int i); ... }; Access to the KDE global objects. KGlobal provides you with pointers of many central objects that exist only once in the process. It is also responsible for managing instances of KStaticDeleterBase. See also KStaticDeleterBase Author Sirtaj Singh Kang (taj@kde.org) |
|
The component currently active (useful in a multi-component application, such as a KParts application). Don't use this - it's mainly for KAboutDialog and KBugReport. Internal |
|
Returns a text for the window caption. This may be set by "-caption", otherwise it will be equivalent to the name of the executable. Returns the text for the window caption |
|
The global charset manager. Returns the global charset manager |
|
Returns the general config object. Returns the global configuration object. |
|
Tells KGlobal that one operation such as those described in ref() just finished. This call makes the QApplication quit if the counter is back to 0. |
|
Returns the application standard dirs object. Returns the global standard dir object |
|
Internal Returns whether KGlobal has a valid KLocale object |
|
Internal Returns whether a main KComponentData is available. |
|
Returns the global locale object. Returns the global locale object |
|
Returns the global component data. There is always at least one instance of a component in one application (in most cases the application itself). Returns the global component data |
|
Tells KGlobal about one more operations that should be finished before the application exits. The standard behavior is to exit on the "last window closed" event, but some events should outlive the last window closed (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client). Note that for this to happen you must call qApp->setQuitOnLastWindowClosed(false), in main() for instance. |
|
Set the active component for use by KAboutDialog and KBugReport. To be used only by a multi-component (KParts) application. See also activeComponent() |
|
Internal |
|
Creates a static QString. To be used inside functions(!) like: static const QString &myString = KGlobal.staticQString("myText"); Do NOT use code such as: static QString myString = KGlobal.staticQString("myText");This creates a static object (instead of a static reference) and as you know static objects are EVIL. str - the string to create Returns the static string |
|
Creates a static QString. To be used inside functions(!) like: static const QString &myString = KGlobal.staticQString(i18n("My Text")); Do NOT use code such as: static QString myString = KGlobal.staticQString(i18n("myText"));This creates a static object (instead of a static reference) and as you know static objects are EVIL. str - the string to create Returns the static string |