QT里的函数void Q_INIT_RESOURCE ( name )

来源:互联网 发布:mysql免安装版 编辑:程序博客网 时间:2024/06/16 08:12

  

QT里的函数voidQ_INIT_RESOURCE ( name )

Initializesthe resources specified by the .qrc file with the specified basename. Normally, Qt resources are loaded automatically at startup.The Q_INIT_RESOURCE() macro is necessary on some platforms forresources stored in a static library

初始
初始初始化的。用指定的基本名称的QRC文件中指定的资源。通常情况下,Qt的资源,在启动时自动加载。在Q_INIT_RESOURCE()宏是必要的关于在静态库中的一些资源平台。

例如,如果您的应用程序的资源在一个文件中列出的所谓myapp.qrc,您可以确保这些资源,在启动时初始化加入这一行main()函数:
Q_INIT_RESOURCE(myapp);

If the file name contains characters thatcannot be part of a valid C++ function name (such as '-'), theyhave to be replaced by the underscore character('_').

Note: This macro cannot be used in anamespace. It should be called from main(). If that is notpossible, the following workaround can be used to init the resourcemyapp from the functionMyNamespace::myFunction:

如果文件名中包含的字符不能成为一个有效的C ++的一部分函数的名称(如'-'),他们必须由('_').下划线字符替换

注意:这不是在一个命名空间中使用宏。应该调用的main()。如果这是不可能的,下面的解决方法可用于从函数初始化myNameSpace对象资源MyApp的::myFunction的:
例如,如果您的应用程序的资源在一个文件中列出的所谓myapp.qrc,您可以确保这些资源,在启动时初始化加入这一行main()函数:
nline void initMyResource() { Q_INIT_RESOURCE(myapp); } namespace MyNamespace {      ...      void myFunction()             initMyResource();      } }
另见Q_CLEANUP_RESOURCE()和Qt的资源系统。

原创粉丝点击