From f087fffde30c0f964415920d2486538afcac181e Mon Sep 17 00:00:00 2001 From: touwoyimuli Date: Sun, 8 Dec 2019 12:16:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20v.1.4.1=20=E5=B0=9D=E8=AF=95=E8=BF=99?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=EF=BC=88=E7=BB=A7=E6=89=BF=E4=BA=8ExxxPrivat?= =?UTF-8?q?e=EF=BC=89=EF=BC=8C=E3=80=80=E4=BD=86=E6=98=AFq=5Ffun()=20?= =?UTF-8?q?=E4=B8=BA=E7=A7=81=E6=9C=89=E6=B2=A1=E6=9C=89=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QtCustomStyleEx/MyWidget/ExSwitchButton.cpp | 1 + QtCustomStyleEx/MyWidget/ExSwitchButton.h | 1 + QtCustomStyleEx/MyWidget/ExSwitchButton_p.h | 6 ++++-- QtCustomStyleEx/QtCustomStyleEx.pro | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp b/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp index 162a0bd..45c3b3b 100644 --- a/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp +++ b/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp @@ -22,6 +22,7 @@ #include "ExSwitchButton.h" //#include "qglobal.h" + EXWIDGET_BEGIN_NAMESPACE //xxxPrivate class 会在 xxx.cpp 里面来实现 diff --git a/QtCustomStyleEx/MyWidget/ExSwitchButton.h b/QtCustomStyleEx/MyWidget/ExSwitchButton.h index 3fb9857..d2d3cd3 100644 --- a/QtCustomStyleEx/MyWidget/ExSwitchButton.h +++ b/QtCustomStyleEx/MyWidget/ExSwitchButton.h @@ -31,6 +31,7 @@ EXWIDGET_BEGIN_NAMESPACE class ExSwitchButton : public QAbstractButton { + Q_OBJECT public: explicit ExSwitchButton(); ~ExSwitchButton(); diff --git a/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h b/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h index 12b30a2..2c4ef74 100644 --- a/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h +++ b/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h @@ -24,18 +24,20 @@ #include "ExMyGlobal.h" #include +#include +#include EXWIDGET_BEGIN_NAMESPACE /*! * \~chinese \class ExSwitchButtonPrivate * \~chinese \brief ExSwitchButton 类的数据类, 便于实现源码/二进制兼容, 通常继承于 “自定义_Private” 的类 + * 若是自定义控件,没有继承于 QObjectPrivate 之类的, 使用 Q_Q Q_D 时候,会报错,需要自己定义 q_fun() 函数 * \~chinese \sa Qt 自带的 QPushButtonPrivate, QPushButton 实现 */ class ExSwitchButton; -class ExSwitchButtonPrivate //自定义控件通常继承于 QObjectPrivate 之类的 -{ +class ExSwitchButtonPrivate : public QObjectPrivate { public: ExSwitchButtonPrivate(ExSwitchButton *qq); ~ExSwitchButtonPrivate(); diff --git a/QtCustomStyleEx/QtCustomStyleEx.pro b/QtCustomStyleEx/QtCustomStyleEx.pro index d7ce2c4..eb5cd90 100644 --- a/QtCustomStyleEx/QtCustomStyleEx.pro +++ b/QtCustomStyleEx/QtCustomStyleEx.pro @@ -4,9 +4,10 @@ # #------------------------------------------------- -QT += core gui +#xxxPrivate 继承 Q-xxxx-Private的话,是需要的添加 core-private(有一些核心方法? 类 可能不开放) +QT += core gui core-private -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets widgets-private # 若是需要继承 widgets相关,需要添加 widgets-private TARGET = custom-style TEMPLATE = app