feat: v1.4.2 创建一个类 ExSwitchButton 和 ExSwitchButtonPrivate 类成功,解决了q_fun() 和 d_fun() 的编译不通过的问题

This commit is contained in:
touwoyimuli 2019-12-11 00:12:10 +08:00
parent 991ea349a5
commit 1565858861
4 changed files with 18 additions and 16 deletions

View File

@ -30,6 +30,8 @@
#include <QSlider>
#include <QScrollBar>
#include "MyWidget/ExSwitchButton.h"
EXWIDGET_USE_NAMESPACE
Example::Example(QWidget *parent)

View File

@ -20,8 +20,8 @@
* along with this program. If not, see <https://touwoyimuli.github.io/>.
*/
#include "ExSwitchButton.h"
//#include "qglobal.h"
#include "ExSwitchButton_p.h"
#include <QDebug>
EXWIDGET_BEGIN_NAMESPACE
@ -29,7 +29,7 @@ EXWIDGET_BEGIN_NAMESPACE
/*!
* \~chinese \brief ExSwitchButtonPrivate
*/
ExSwitchButtonPrivate::ExSwitchButtonPrivate(ExSwitchButton *qq)
ExSwitchButtonPrivate::ExSwitchButtonPrivate(/*ExSwitchButton *qq*/)
{
}
@ -48,11 +48,7 @@ void ExSwitchButtonPrivate::init()
q->setCheckable(true);
q->connect(q, SIGNAL(toggled(bool)), q, SLOT(onChange(bool)));
}
ExSwitchButtonPrivate::ExSwitchButton()
{
q->onChange(true);
}
void ExSwitchButton::onChange(bool)
@ -65,7 +61,4 @@ void ExSwitchButton::onChange(bool)
}
EXWIDGET_END_NAMESPACE

View File

@ -23,21 +23,24 @@
#define EXSWITCHBUTTON_H
#include "ExMyGlobal.h"
#include "ExSwitchButton_p.h"
#include <QtGlobal>
#include <QAbstractButton>
EXWIDGET_BEGIN_NAMESPACE
class ExSwitchButtonPrivate; //Q_DECLARE_PRIVATE() 宏展开使用的
class ExSwitchButton : public QAbstractButton
{
Q_OBJECT
public:
explicit ExSwitchButton();
~ExSwitchButton();
private slots:
void onChange(bool);
private:
Q_DECLARE_PRIVATE(ExSwitchButton)
};
EXWIDGET_END_NAMESPACE

View File

@ -36,16 +36,20 @@ EXWIDGET_BEGIN_NAMESPACE
* \~chinese \sa Qt QPushButtonPrivate QPushButton
*/
class ExSwitchButton;
class ExSwitchButtonPrivate : public QObjectPrivate {
class ExSwitchButtonPrivate : public QObjectPrivate
{
public:
ExSwitchButtonPrivate(ExSwitchButton *qq);
explicit ExSwitchButtonPrivate();
~ExSwitchButtonPrivate();
void init();
public:
bool m_checked; //switch 是否处于开启状态
public:
Q_DECLARE_PUBLIC(ExSwitchButton) //要加上宏
};
EXWIDGET_END_NAMESPACE