feat: Repaint the skin of a custom control, and the painting is complete
MyStyle has completed, QStylePainter's inheritance rewrite has not yet started
This commit is contained in:
29
QtMyStyleEx/QtExample03/QtStyleEx/myswitchbutton.h
Normal file
29
QtMyStyleEx/QtExample03/QtStyleEx/myswitchbutton.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef MYSWITCHBUTTON_H
|
||||
#define MYSWITCHBUTTON_H
|
||||
|
||||
#include <QAbstractButton>
|
||||
class QStyleOptionButton;
|
||||
|
||||
class MySwitchButtonPrivate;
|
||||
class MySwitchButton : public QAbstractButton//bianxinagjicengle QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MySwitchButton(QWidget* parent = nullptr);
|
||||
~MySwitchButton();
|
||||
|
||||
// QWidget interface
|
||||
public:
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
void initStyleOption(QStyleOptionButton *opt) const;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(MySwitchButton)
|
||||
};
|
||||
|
||||
#endif // MYSWITCHBUTTON_H
|
||||
Reference in New Issue
Block a user