From 17dc1f5d42b47362c31a0ee2c6fde5869d48488b Mon Sep 17 00:00:00 2001 From: xmuli Date: Sat, 28 Mar 2020 17:33:20 +0800 Subject: [PATCH] feat: The custom control MySwitchButton has been implemented --- QtCustomStyleEx/ExMyGlobal.h | 35 ---- QtCustomStyleEx/ExMyStyle.cpp | 158 ------------------ QtCustomStyleEx/ExMyStyle.h | 153 ----------------- QtCustomStyleEx/Example.cpp | 92 ---------- QtCustomStyleEx/Example.h | 40 ----- QtCustomStyleEx/MyWidget/ExSwitchButton.cpp | 105 ------------ QtCustomStyleEx/MyWidget/ExSwitchButton.h | 56 ------- QtCustomStyleEx/MyWidget/ExSwitchButton_p.h | 59 ------- QtCustomStyleEx/QtCustomStyleEx.pro | 45 ----- QtCustomStyleEx/images/icon.icns | Bin 11126 -> 0 bytes QtCustomStyleEx/images/icon.ico | Bin 4286 -> 0 bytes QtCustomStyleEx/main.cpp | 44 ----- QtMyStyleEx/Example.cpp | 11 -- QtMyStyleEx/Example.h | 14 -- QtMyStyleEx/QtExample03/QtStyleEx/mystyle.cpp | 20 --- QtMyStyleEx/QtExample03/QtStyleEx/mystyle.h | 16 +- .../QtExample03/QtStyleEx/myswitchbutton.cpp | 2 +- QtMyStyleEx/QtMyStyleEx.pro | 28 ---- QtMyStyleEx/main.cpp | 11 -- 19 files changed, 5 insertions(+), 884 deletions(-) delete mode 100644 QtCustomStyleEx/ExMyGlobal.h delete mode 100644 QtCustomStyleEx/ExMyStyle.cpp delete mode 100644 QtCustomStyleEx/ExMyStyle.h delete mode 100644 QtCustomStyleEx/Example.cpp delete mode 100644 QtCustomStyleEx/Example.h delete mode 100644 QtCustomStyleEx/MyWidget/ExSwitchButton.cpp delete mode 100644 QtCustomStyleEx/MyWidget/ExSwitchButton.h delete mode 100644 QtCustomStyleEx/MyWidget/ExSwitchButton_p.h delete mode 100644 QtCustomStyleEx/QtCustomStyleEx.pro delete mode 100644 QtCustomStyleEx/images/icon.icns delete mode 100644 QtCustomStyleEx/images/icon.ico delete mode 100644 QtCustomStyleEx/main.cpp delete mode 100644 QtMyStyleEx/Example.cpp delete mode 100644 QtMyStyleEx/Example.h delete mode 100644 QtMyStyleEx/QtMyStyleEx.pro delete mode 100644 QtMyStyleEx/main.cpp diff --git a/QtCustomStyleEx/ExMyGlobal.h b/QtCustomStyleEx/ExMyGlobal.h deleted file mode 100644 index fe69a87..0000000 --- a/QtCustomStyleEx/ExMyGlobal.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef EXMYGLOBAL_H -#define EXMYGLOBAL_H - -//定义命名空间宏 -#define EXWIDGET_BEGIN_NAMESPACE namespace ExPlumStyle { -#define EXWIDGET_END_NAMESPACE } - -#define EXWIDGET_USE_NAMESPACE using namespace ExPlumStyle; - -//ExPlumStyle命名空间里面嵌套的的子命名空间 -#define EXDRAWUTILS_BEGIN_NAMESPACE namespace ExDrawUtils { -#define EXDRAWUTILS_END_NAMESPACE } - -#endif // EXMYGLOBAL_H diff --git a/QtCustomStyleEx/ExMyStyle.cpp b/QtCustomStyleEx/ExMyStyle.cpp deleted file mode 100644 index 8b2f911..0000000 --- a/QtCustomStyleEx/ExMyStyle.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "ExMyStyle.h" - -#include -#include -#include -#include -#include - -EXWIDGET_BEGIN_NAMESPACE -ExMyStyle::ExMyStyle() -{ - -} - -void ExMyStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const -{ - -} - - - -void ExMyStyle::polish(QWidget *widget) -{ - QCommonStyle::polish(widget); -} - -void ExMyStyle::unpolish(QWidget *widget) -{ - QCommonStyle::unpolish(widget); -} - -void ExMyStyle::drawControl(QStyle::ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const -{ - p->setRenderHint(QPainter::Antialiasing); - - switch (element) { - case CE_ScrollBarAddPage: { //增加页(在滑槽) - p->fillRect(opt->rect, QColor("#bfe9ff")); - return; - } - case CE_ScrollBarSubPage: { //减少页(在滑槽) - p->fillRect(opt->rect, QColor("#EC6EAD")); - return; - } - case CE_ScrollBarSlider: { //滑块 - p->fillRect(opt->rect, QColor("#A8BFFF")); - return; - } - case CE_ScrollBarAddLine: { //增加按钮 - p->fillRect(opt->rect, QColor("#21d4fd")); - return; - } - case CE_ScrollBarSubLine: { //减少按钮 - p->fillRect(opt->rect, QColor("#de6161")); - return; - } - default: - break; - } - - QCommonStyle::drawControl(element, opt, p, w); -} - -void ExMyStyle::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const -{ - switch (cc) { -// case CC_: -// break; - default: - break; - } - - QCommonStyle::drawComplexControl(cc, opt, p, widget); -} - -QSize ExMyStyle::sizeFromContents(QStyle::ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const -{ - QSize size = QCommonStyle::sizeFromContents(ct, opt, contentsSize, w); - - switch (ct) { - case CT_ScrollBar: { - int widget = size.width(); - int height = size.height(); - - if (widget < height) - size.setHeight(height * 1.2); - - if (widget > height) - size.setWidth(widget * 1.2); - - qDebug()<<"----01----:"< - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef EXMYSTYLE_H -#define EXMYSTYLE_H - -#include "ExMyGlobal.h" - -#include "qglobal.h" -#include - -QT_BEGIN_NAMESPACE -//class QCommonStyle; -QT_END_NAMESPACE - -EXWIDGET_BEGIN_NAMESPACE -class ExMyStyle : public QCommonStyle -{ -// Q_OBJECT - -public: - ExMyStyle(); - -// enum ControlElement { -// CE_SwitchButton = QStyle::CE_CustomBase + 1, -// CE_CustomBase = QStyle::CE_CustomBase + 0xf00000 -// }; - -public: -// enum PrimitiveElement { -// PE_ItemBackground = QStyle::PE_CustomBase + 1, //列表项的背景色 -// PE_SwitchButtonGroove, -// PE_SwitchButtonHandle, -// PE_CustomBase = QStyle::PE_CustomBase + 0xf00000 -// }; - -// enum ControlElement { -// CE_IconButton = QStyle::CE_CustomBase + 1, -// CE_SwitchButton, -// CE_CustomBase = QStyle::CE_CustomBase + 0xf00000 -// }; - -// enum SubElement { -// SE_IconButtonIcon = QStyle::SE_CustomBase + 1, -// SE_SwitchButtonGroove, -// SE_SwitchButtonHandle, -// SE_CustomBase = QStyle::SE_CustomBase + 0xf00000 -// }; - -// enum PixelMetric { -// PM_FocusBorderWidth = QStyle::PM_CustomBase + 1, //控件焦点状态的边框宽度 -// PM_FrameRadius, -// PM_CustomBase = QStyle::PM_CustomBase + 0xf00000 -// }; - -// enum ContentsType { -// CT_IconButton = QStyle::CT_CustomBase + 1, -// CT_SwitchButton, -// CT_CustomBase = QStyle::CT_CustomBase + 0xf00000 -// }; - -// enum StyleHint { -// SH_CustomBase = QStyle::SH_CustomBase + 0xf00000 -// }; - -// enum StandardPixmap { -// SP_CustomBase = QStyle::SP_CustomBase + 0xf00000 -// }; - -// /*枚举通过按位 ~ ^ | !来计算得到需要组合 -// * //0b对应的二进制 0x十六进制 对应的十进制 -// * 0b0000 0001 0x0000 0001 1 -// * 0b0000 0010 0x0000 0002 2 -// * 0b0000 0100 0x0000 0004 4 -// * 0b0000 1000 0x0000 0006 8 -// * 0b0001 0000 0x0000 0010 16 -// */ - -// enum StyleState { -// SS_NormalState = 0x00000000, -// SS_HoverState = 0x00000001, -// SS_PressState = 0x00000002, -// }; -// Q_DECLARE_FLAGS(StateFlags, StyleState) //而类型定义(typedef)和操作符重载正是宏Q_DECLARE_FLAGS 和 Q_DECLARE_OPERATORS_FOR_FLAGS (均无关于元对象系统) - - //静态static函数 -// static void drawPrimitive(const QStyle *style, ExCustomStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w); -// static void drawControl(const QStyle *style, ExCustomStyle::ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w); -// static int pixelMetric(const QStyle *style, QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget); -// static QRect subElementRect(const QStyle *style, ExCustomStyle::SubElement subElement, const QStyleOption *option, const QWidget *widget); -// static QSize sizeFromContents(const QStyle *style, ExCustomStyle::ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w); -// static QIcon standardIcon(const QStyle *style, ExCustomStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget); - - - //内联inline函数,然后[自动选择]是调用静态函数,还是重写的基类的函数 - inline void drawPrimitive(ExMyStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const; -// inline void drawControl(ExCustomStyle::ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const; -// inline QRect subElementRect(ExCustomStyle::SubElement subElement, const QStyleOption *option, const QWidget *widget) const; -// inline int pixelMetric(ExCustomStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const; -// inline QSize sizeFromContents(ExCustomStyle::ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const; -// inline int styleHint(ExCustomStyle::StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const; - -// inline void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const; //这三个不用写成内联函数,且会编译不通过 -// inline QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; -// inline QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const; -// virtual void polish(QPalette &palette) override; //通常在此函数内指定配色方案,也即配置调色板 -// virtual void polish(QWidget *widget) override; //当样式应用到窗口部件时,polish(QWidget*)就会调用,从而允许我们进行最后的定制 -// virtual void unpolish(QWidget *widget) override; //当动态改变样式的时候,unpolish就会调用,来撤销polish的影响。polish(QWidget*)一般用做窗口部件的事件过滤器。 - - // QStyle interface 重写QCommonStyle重载的函数 -public: - virtual void polish(QWidget *widget) override; - virtual void unpolish(QWidget *widget) override; - virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const override; - virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const override; - virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const override; - virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget) const override; - virtual int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const override; - virtual int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const override; - - - //重实现,使得父类的多个同名 函数 (不同参数) 任然可以在本类里面使用 - using QCommonStyle::drawPrimitive; - using QCommonStyle::drawControl; - using QCommonStyle::subElementRect; - using QCommonStyle::pixelMetric; - using QCommonStyle::sizeFromContents; - using QCommonStyle::styleHint; - using QCommonStyle::standardIcon; - -public: -}; -EXWIDGET_END_NAMESPACE - -#endif // EXMYSTYLE_H diff --git a/QtCustomStyleEx/Example.cpp b/QtCustomStyleEx/Example.cpp deleted file mode 100644 index 08ffafd..0000000 --- a/QtCustomStyleEx/Example.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "Example.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "MyWidget/ExSwitchButton.h" - -EXWIDGET_USE_NAMESPACE - -Example::Example(QWidget *parent) - : QWidget(parent) -{ - -} - -Example::~Example() -{ - -} - -void Example::init() -{ - QTableWidget *table = new QTableWidget(10, 10, this); - QScrollBar *scrollBarH = new QScrollBar(this); - QScrollBar *scrollBarV = new QScrollBar(this); - - table->move(10, 10); - - scrollBarH->move(300, 50); - scrollBarH->setRange(0, 100); - scrollBarH->setValue(34); - scrollBarH->resize(380, 20); - scrollBarH->setOrientation(Qt::Horizontal); - - scrollBarV->move(50, 250); - scrollBarV->setRange(0, 100); - scrollBarV->setValue(67); - scrollBarV->resize(20, 380); - scrollBarV->setOrientation(Qt::Vertical); - - int i = 0; - QStringList listStyle = QStyleFactory::keys(); - foreach(QString val, listStyle) { //打印当前系统支持的系统风格 - QPushButton *btn = new QPushButton(val, this); - btn->move(this->rect().right() - 100, this->rect().top() + i++ * 40); - connect(btn, &QPushButton::clicked, this, [=](){ - qApp->setStyle(val); - }); - } - - QPushButton *btn = new QPushButton("ExMyStyle", this); - btn->move(this->rect().right() - 100, this->rect().top() + i++ * 40); - connect(btn, &QPushButton::clicked, this, [=](){ - qApp->setStyle(new ExMyStyle()); - }); - - ExSwitchButton* switchBtn = new ExSwitchButton(); - switchBtn->move(300, 300); -// switchBtn->move(700, 500); - switchBtn->resize(200, 200); - switchBtn->setText("switchBtn"); - switchBtn->setParent(this); - switchBtn->show(); - qDebug()<<"----03-----------------"<rect(); -} diff --git a/QtCustomStyleEx/Example.h b/QtCustomStyleEx/Example.h deleted file mode 100644 index dc0e8c9..0000000 --- a/QtCustomStyleEx/Example.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef EXAMPLE_H -#define EXAMPLE_H - -#include //Qt的库 - -#include "ExMyStyle.h" //自己的库 - -class Example : public QWidget -{ - Q_OBJECT - -public: - Example(QWidget *parent = 0); - ~Example(); - - void init(); -}; - -#endif // EXAMPLE_H diff --git a/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp b/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp deleted file mode 100644 index 56f0b93..0000000 --- a/QtCustomStyleEx/MyWidget/ExSwitchButton.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "ExSwitchButton.h" -#include "ExSwitchButton_p.h" -#include -#include -#include "ExMyStyle.h" - -EXWIDGET_BEGIN_NAMESPACE - -//xxxPrivate class 会在 xxx.cpp 里面来实现 -/*! - * \~chinese \brief ExSwitchButtonPrivate 的构造函数 - */ -ExSwitchButtonPrivate::ExSwitchButtonPrivate(/*ExSwitchButton *qq*/) -{ - init(); -} - -ExSwitchButtonPrivate::~ExSwitchButtonPrivate() -{ - -} - -void ExSwitchButtonPrivate::init() -{ - m_checked = false; //xxxxPrivate 自带的变量 - Q_Q(ExSwitchButton); //Q_Q 可以在 xxxxPrivate 里面调用 xxxx 的方法和变量 - - q->setObjectName("ExSwitchButtonPrivate"); - q->setCheckable(true); - q->connect(q, SIGNAL(toggled(bool)), q, SLOT(onChange(bool))); - - q->onChange(true); -} - -ExSwitchButton::ExSwitchButton() -{ - Q_D(ExSwitchButton); -} - -ExSwitchButton::~ExSwitchButton() -{ - -} - -void ExSwitchButton::onChange(bool) -{ - Q_D(ExSwitchButton); - - d->m_checked = (!d->m_checked); - - qDebug()<<"------01-----ExSwitchButton::onChange(bool):"<m_checked; -} - -void ExSwitchButton::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - - QPainter painter(this); - QStyleOptionButton opt; - initStyleOption(&opt); - - ExMyStyle MyStyle; -// MyStyle.drawControl(ExMyStyle::CE_Sw); - - -} - -void ExSwitchButton::initStyleOption(QStyleOptionButton *option) const -{ - if (!option) - return; - - option->init(this); //QStyleOption 对象进行初始化(其中属性很多,整体初始化,然后局部进行参数修改) - option->initFrom(this); - - if (isChecked()) { - option->state |= QStyle::State_On; - } else { - option->state |= QStyle::State_Off; - } -} - - -EXWIDGET_END_NAMESPACE diff --git a/QtCustomStyleEx/MyWidget/ExSwitchButton.h b/QtCustomStyleEx/MyWidget/ExSwitchButton.h deleted file mode 100644 index 0da3126..0000000 --- a/QtCustomStyleEx/MyWidget/ExSwitchButton.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef EXSWITCHBUTTON_H -#define EXSWITCHBUTTON_H - -#include "ExMyGlobal.h" -#include - -#include -#include -//#include - -EXWIDGET_BEGIN_NAMESPACE - -class ExSwitchButtonPrivate; //Q_DECLARE_PRIVATE() 宏展开使用的 -class ExSwitchButton : public QAbstractButton -{ -public: - explicit ExSwitchButton(); - ~ExSwitchButton(); - -private slots: - void onChange(bool); - -private: - Q_DECLARE_PRIVATE(ExSwitchButton) - - // QWidget interface -protected: - virtual void paintEvent(QPaintEvent *event) override; //必须重载的纯虚函数 - void initStyleOption(QStyleOptionButton* option) const; - -}; - -EXWIDGET_END_NAMESPACE - -#endif diff --git a/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h b/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h deleted file mode 100644 index b60251d..0000000 --- a/QtCustomStyleEx/MyWidget/ExSwitchButton_p.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef EXSWITCHBUTTON_P_H -#define EXSWITCHBUTTON_P_H - -#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 ExSwitchButtonPrivate : public QObjectPrivate -{ -public: - explicit ExSwitchButtonPrivate(); - ~ExSwitchButtonPrivate(); - -// virtual ~QObjectData(); - - void init(); - -public: - bool m_checked; //switch 是否处于开启状态 - -public: - Q_DECLARE_PUBLIC(ExSwitchButton) //要加上宏 -}; - -EXWIDGET_END_NAMESPACE - -#endif diff --git a/QtCustomStyleEx/QtCustomStyleEx.pro b/QtCustomStyleEx/QtCustomStyleEx.pro deleted file mode 100644 index eb5cd90..0000000 --- a/QtCustomStyleEx/QtCustomStyleEx.pro +++ /dev/null @@ -1,45 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-11-07T16:47:52 -# -#------------------------------------------------- - -#xxxPrivate 继承 Q-xxxx-Private的话,是需要的添加 core-private(有一些核心方法? 类 可能不开放) -QT += core gui core-private - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets widgets-private # 若是需要继承 widgets相关,需要添加 widgets-private - -TARGET = custom-style -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - Example.cpp \ - ExMyStyle.cpp \ - MyWidget/ExSwitchButton.cpp - -HEADERS += \ - Example.h \ - ExMyStyle.h \ - ExMyGlobal.h \ - MyWidget/ExSwitchButton.h \ - MyWidget/ExSwitchButton_p.h - - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/QtCustomStyleEx/images/icon.icns b/QtCustomStyleEx/images/icon.icns deleted file mode 100644 index 9d5eb31f9fdab410eb005d0b29a939f2c088e97b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11126 zcmY+q2UJtR*04>JUKIfWrK$+1C`c2f2nr~@D2OycX-Y>Bkx-@gE=4-h1f&Vld+)sk z5>kMW0wD>IQWG2pUKYCM9N%=Xyy?39A>RLs#q5d;A zW`1TWDk?S|ZB1iJs`l^8NJF__XMsdh5^8VbXBt$slY($c2}>PKbyKGcd7oE)i7y4% zAOc?^$2O4b7Q+_eG55ucy`*n7fE2GW>s)hVtYf_yz|2WUfAQ|!ueu~UT6Jr;KAl`) zb{etJ4=Z+jG0B%dw>oJ~KK|6T5fq55-CO-c*7x0d_{qumc}!p1f?4?_;RJ~bDu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c7qGR&t!xn(2WV=;jU7FNA!)Krh;43^sd^c~z*x zD!q4{{k{>M>~luekydMilU#JHn-IC{^>*|QSm@sbX6C}wHp^=d#wHZT89*=?#f&b7 zzV0vZ#nFxE|LOqTUIzxR>CxXehl%kym@O{mAjpAB06h8m*2Idz6(zhOO0=I7)S;uJktllW1j(ktW~V(l!!Vi9-=Xl5LknY9r&CcWYD z#^LcOm|KWpWFpR-#ARGpuTJuQRMx(mUKwT&Thf~(??@yfy&!skz`xRcL9PxbdkeoS zdY#7`Mw0ku;x2GziFqZk#wTr2TCYHjTQK* zvz4#C9lOeybaXe!dY3?U*te=R+KQqE6N(lZ@Iu953E@gbNiWo$FBsed` zA@1c_BmO`bMPA1fD>4r*cMM79M(C1bUl)Baoz6*~!C;u*5E_J7dloD&JLJE`_wuXf36rFcaRi`kM+r(}MGR;#>c zT6VMFI_}I|p{3EE!XnQE^OR?9P3(_tjA>#^5gi*E{UF~%V3!sk^mqcOtE zn#|Cv1?F9F6u5~*0%6u%I$f%t_1`I9i@jGUx+2dkxr;qm`PqM4MGS&VHp@L1HE=oo lFfQ3)vv5z!IUS9}WQXnlmvdMCe}Mnj`X9zA(Ix-@ diff --git a/QtCustomStyleEx/main.cpp b/QtCustomStyleEx/main.cpp deleted file mode 100644 index 89d89ff..0000000 --- a/QtCustomStyleEx/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2019 ~ 2019 touwoyimuli. All rights reserved. - * - * Author: touwoyimuli - * - * github: https://github.com/touwoyimuli - * blogs: https://touwoyimuli.github.io/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "Example.h" -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //若为系统自带的QStyle,则qApp->setStyle("系统自带风格"); - //若为自定义新的QStyle,则qApp->setStyle(QStyleFactory::create("自定义风格")) - QStringList listStyle = QStyleFactory::keys(); - foreach(QString val, listStyle) //打印当前系统支持的系统风格 - qDebug()<setStyle("chameleon"); //Windows/Fusion/... - Example *w = new Example(); - w->resize(1000, 700); - w->init(); - w->show(); - - return a.exec(); -} diff --git a/QtMyStyleEx/Example.cpp b/QtMyStyleEx/Example.cpp deleted file mode 100644 index 3adc101..0000000 --- a/QtMyStyleEx/Example.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Example.h" - -Example::Example(QWidget *parent) - : QWidget(parent) -{ -} - -Example::~Example() -{ -} - diff --git a/QtMyStyleEx/Example.h b/QtMyStyleEx/Example.h deleted file mode 100644 index 754764f..0000000 --- a/QtMyStyleEx/Example.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef EXAMPLE_H -#define EXAMPLE_H - -#include - -class Example : public QWidget -{ - Q_OBJECT - -public: - Example(QWidget *parent = nullptr); - ~Example(); -}; -#endif // EXAMPLE_H diff --git a/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.cpp b/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.cpp index c5c77ae..6f6b913 100644 --- a/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.cpp +++ b/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.cpp @@ -65,31 +65,11 @@ QRect MyStyle::subElementRect(MyStyle::SubElement subElement, const QStyleOption return proxy()->subElementRect(static_cast(subElement), option, widget); } -//void MyStyle::drawComplexControl(MyStyle::ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const -//{ - -//} - -//QRect MyStyle::subControlRect(MyStyle::ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const -//{ -// return QRect(); -//} - int MyStyle::pixelMetric(MyStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { return proxy()->pixelMetric(static_cast(metric), option, widget); } -//QSize MyStyle::sizeFromContents(MyStyle::ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const -//{ -// return QSize(); -//} - -//int MyStyle::styleHint(MyStyle::StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const -//{ -// return 0; -//} - void MyStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); diff --git a/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.h b/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.h index 53b8312..f57b658 100644 --- a/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.h +++ b/QtMyStyleEx/QtExample03/QtStyleEx/mystyle.h @@ -64,22 +64,14 @@ public: static void drawPrimitive(const QStyle *style, MyStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = nullptr); static void drawControl(const QStyle *style, MyStyle::ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w); static QRect subElementRect(const QStyle *style, MyStyle::SubElement subElement, const QStyleOption *option, const QWidget *widget); -// static void drawComplexControl(const QStyle *style, MyStyle::ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const; -// static QRect subControlRect(const QStyle *style, MyStyle::ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; static int pixelMetric(const QStyle *style, MyStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget); -// static QSize sizeFromContents(const QStyle *style, MyStyle::ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const; -// static int styleHint(const QStyle *style, MyStyle::StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const; //新增加的枚举属 MyStyle:: , 之能够在此内敛函数里面调用 //[主要用来绘画 自定义新增 的控件枚举 --> 实际调用在 下面的 virtual 里面绘画] inline void drawPrimitive(MyStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = nullptr) const; inline void drawControl(MyStyle::ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const; inline QRect subElementRect(MyStyle::SubElement subElement, const QStyleOption *option, const QWidget *widget) const; -// inline void drawComplexControl(MyStyle::ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const; -// inline QRect subControlRect(MyStyle::ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; inline int pixelMetric(MyStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const; -// inline QSize sizeFromContents(MyStyle::ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const; -// inline int styleHint(MyStyle::StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const; //这里的快捷方式创建的枚举,都是不带QStyle:: ; 但是快捷方式的定义是带是QStyle:: , 此处声明的地方必须加上 QStyle:: /*后面改写更复杂的得写上MyStyle:: 因添加自定义的枚举*/ //这里 override 的虚函数,只能够调用旧有的 QStyle:: 的函数 @@ -135,10 +127,10 @@ public: MyStylePainter(QWidget* w); ~MyStylePainter() {} - /*inline*/ void drawPrimitive(MyStyle::PrimitiveElement pe, const QStyleOption *opt); - /*inline*/ void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption *opt); - /*inline*/ void drawControl(MyStyle::ControlElement element, const QStyleOption *opt); - /*inline*/ void drawControl(QStyle::ControlElement element, const QStyleOption *opt); + void drawPrimitive(MyStyle::PrimitiveElement pe, const QStyleOption *opt); + void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption *opt); + void drawControl(MyStyle::ControlElement element, const QStyleOption *opt); + void drawControl(QStyle::ControlElement element, const QStyleOption *opt); private: QWidget* m_widget; diff --git a/QtMyStyleEx/QtExample03/QtStyleEx/myswitchbutton.cpp b/QtMyStyleEx/QtExample03/QtStyleEx/myswitchbutton.cpp index 158b369..351d241 100644 --- a/QtMyStyleEx/QtExample03/QtStyleEx/myswitchbutton.cpp +++ b/QtMyStyleEx/QtExample03/QtStyleEx/myswitchbutton.cpp @@ -67,7 +67,7 @@ void MySwitchButtonPrivate::init() check = false; q->setObjectName("MySwitchButton"); q->setChecked(true); - q->setCheckable(true); //clicked toggled douxuyaokauqi + q->setCheckable(true); //clicked toggled 都需要开启 q->connect(q, SIGNAL(clicked(bool)), q, SLOT(setChecked(bool))); } diff --git a/QtMyStyleEx/QtMyStyleEx.pro b/QtMyStyleEx/QtMyStyleEx.pro deleted file mode 100644 index 7381416..0000000 --- a/QtMyStyleEx/QtMyStyleEx.pro +++ /dev/null @@ -1,28 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - Example.cpp - -HEADERS += \ - Example.h - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/QtMyStyleEx/main.cpp b/QtMyStyleEx/main.cpp deleted file mode 100644 index 6f3c24c..0000000 --- a/QtMyStyleEx/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Example.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Example w; - w.show(); - return a.exec(); -}