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的资源系统。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值