栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

QT笔记——QT中c++11相关宏了解

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

QT笔记——QT中c++11相关宏了解

一:Q_DISABLE_COPY(Class)

#define Q_DISABLE_COPY(Class) 
    Class(const Class &) Q_DECL_EQ_DELETE;
    Class &operator=(const Class &) Q_DECL_EQ_DELETE;

这是一个拷贝构造 和 赋值函数 ,可以在单利模式的时候使用,我们可以将系统自带的赋值 和 拷贝禁用
Q_DISABLE_COPY(Test) 展开后:

Test(const Test&) delete;
Test&operator=(const Test&) delete;

二:Q_DECL_EQ_DELETE
c++11中的 delete

#ifdef Q_COMPILER_DELETE_MEMBERS
# define Q_DECL_EQ_DELETE = delete
#else
# define Q_DECL_EQ_DELETE
#endif

三:Q_NULLPTR
c++11 中的 nullptr

#ifdef Q_COMPILER_NULLPTR
# define Q_NULLPTR         nullptr
#else
# define Q_NULLPTR         NULL
#endif

四:Q_DECL_EQ_DEFAULT
c++11 中的 default

#ifdef Q_COMPILER_DEFAULT_MEMBERS
#  define Q_DECL_EQ_DEFAULT = default
#else
#  define Q_DECL_EQ_DEFAULT
#endif

五:Q_WIDGETS_EXPORT
作用:导入 和 导出

#ifndef QT_STATIC
#  if defined(QT_BUILD_WIDGETS_LIB)
#    define Q_WIDGETS_EXPORT Q_DECL_EXPORT
#  else
#    define Q_WIDGETS_EXPORT Q_DECL_IMPORT
#  endif
#else
#  define Q_WIDGETS_EXPORT
#endif

间接转化为 :

#  define Q_DECL_EXPORT __declspec(dllexport)
#  define Q_DECL_IMPORT __declspec(dllimport)

QT 常用的 signals and slots

# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal)
相当于  signals:
# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot)
相当于: slots:
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1029946.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号