Obsolete Members for QGlobalStatic

以下成员源于类 QGlobalStatic 被弃用。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

公共函数

(弃用) QGlobalStatic::Type * operator() ()

(弃用) Q_GLOBAL_STATIC_WITH_ARGS ( Type , VariableName , 自变量 )

成员函数文档编制

QGlobalStatic::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.

此函数相当于 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.

宏文档编制

Q_GLOBAL_STATIC_WITH_ARGS ( Type , VariableName , 自变量 )

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, outside of any function bodies):

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

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

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

Aside from the actual initialization of the contents with the supplied arguments, this macro behaves identically to Q_GLOBAL_STATIC (). Please see that macro's documentation for more information.

另请参阅 Q_GLOBAL_STATIC () 和 QGlobalStatic .