feat: v.1.4.1 尝试这添加一个自定义控件(继承于xxxPrivate), 但是q_fun() 为私有没有解决

This commit is contained in:
touwoyimuli 2019-12-08 12:16:00 +08:00
parent 19d8cade29
commit f087fffde3
4 changed files with 9 additions and 4 deletions

View File

@ -22,6 +22,7 @@
#include "ExSwitchButton.h" #include "ExSwitchButton.h"
//#include "qglobal.h" //#include "qglobal.h"
EXWIDGET_BEGIN_NAMESPACE EXWIDGET_BEGIN_NAMESPACE
//xxxPrivate class 会在 xxx.cpp 里面来实现 //xxxPrivate class 会在 xxx.cpp 里面来实现

View File

@ -31,6 +31,7 @@ EXWIDGET_BEGIN_NAMESPACE
class ExSwitchButton : public QAbstractButton class ExSwitchButton : public QAbstractButton
{ {
Q_OBJECT
public: public:
explicit ExSwitchButton(); explicit ExSwitchButton();
~ExSwitchButton(); ~ExSwitchButton();

View File

@ -24,18 +24,20 @@
#include "ExMyGlobal.h" #include "ExMyGlobal.h"
#include <QWidget> #include <QWidget>
#include <QtGlobal>
#include <private/qobject_p.h>
EXWIDGET_BEGIN_NAMESPACE EXWIDGET_BEGIN_NAMESPACE
/*! /*!
* \~chinese \class ExSwitchButtonPrivate * \~chinese \class ExSwitchButtonPrivate
* \~chinese \brief ExSwitchButton 便/, _Private * \~chinese \brief ExSwitchButton 便/, _Private
* , QObjectPrivate , 使 Q_Q Q_D q_fun()
* \~chinese \sa Qt QPushButtonPrivate QPushButton * \~chinese \sa Qt QPushButtonPrivate QPushButton
*/ */
class ExSwitchButton; class ExSwitchButton;
class ExSwitchButtonPrivate //自定义控件通常继承于 QObjectPrivate 之类的 class ExSwitchButtonPrivate : public QObjectPrivate {
{
public: public:
ExSwitchButtonPrivate(ExSwitchButton *qq); ExSwitchButtonPrivate(ExSwitchButton *qq);
~ExSwitchButtonPrivate(); ~ExSwitchButtonPrivate();

View File

@ -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 TARGET = custom-style
TEMPLATE = app TEMPLATE = app