QT————Q_INIT_RESOURCE

转载地址:http://blog.163.com/seven_7_one/blog/static/162606412201092713131191/

QT里的函数void Q_INIT_RESOURCE ( name )

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

 

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

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

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

Note: This macro cannot be used in a namespace. It should be called from main(). If that is not possible, the following workaround can be used to init the resource myapp from the function MyNamespace::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的资源系统。

原文地址:https://www.cnblogs.com/corecible/p/2040608.html