- Qt 6.9
- Qt Core
- C++ Classes
- QGlobalStatic
- Qt 6.9.3 Reference Documentation

# Obsolete Members for QGlobalStatic

The following members of class QGlobalStatic are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(deprecated)` QGlobalStatic<Holder>::Type * | operator()()

## Macros

`(deprecated)` | Q_GLOBAL_STATIC_WITH_ARGS(Type, variableName, Arguments)

## Member Function Documentation

### `[deprecated]` QGlobalStatic<Holder>::Type *QGlobalStatic::operator()()

This function is deprecated. We strongly advise against using it in new code.

This function returns the address of the contents of this global static. If the contents have not yet been created, they will be created thread-safely by this function. If the contents have already been destroyed, this function will return a null pointer.

This function is equivalent to operator Type *(). It is provided for compatibility with the private Q_GLOBAL_STATIC implementation that existed in Qt 4.x and 5.0. New code should avoid using it and should instead treat the object as a smart pointer.

## Macro Documentation

### `[deprecated]` Q_GLOBAL_STATIC_WITH_ARGS(Type, variableName, Arguments)

This macro is deprecated. We strongly advise against using it in new code.

Creates a global and static object of type QGlobalStatic, of name variableName, initialized by the arguments Arguments and that behaves as a pointer to Type. The object created by Q_GLOBAL_STATIC_WITH_ARGS initializes itself on the first use, which means that it will not increase the application or the library's load time. Additionally, the object is initialized in a thread-safe manner on all platforms.

The typical use of this macro is as follows, in a global context (that is, not inside any function or class body):

     Q_GLOBAL_STATIC_WITH_ARGS(MyType, myGlobal, (42, "Hello", "World"))

The Arguments macro parameter must always be enclosed in parentheses or, if C++11 uniform initialization is allowed, braces. The above call is equivalent to

     Q_GLOBAL_STATIC(MyType, myGlobal, 42, "Hello", "World")

Aside from needing the supplied arguments enclosed, this macro behaves identically to Q_GLOBAL_STATIC(). Please see that macro's documentation for more information.

See also Q_GLOBAL_STATIC() and QGlobalStatic.