一: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:



