feat: v.1.4.1 尝试这添加一个自定义控件(继承于xxxPrivate), 但是q_fun() 为私有没有解决
This commit is contained in:
parent
19d8cade29
commit
f087fffde3
@ -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 里面来实现
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user