make mental note that QAbstractButton subclass needs to implement sizeHint
This commit is contained in:
parent
401bf7a95a
commit
b6c862e2d5
|
@ -1,4 +1,6 @@
|
|||
#include <QAbstractButton>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include "toggle.h"
|
||||
#include "../lib/rippleoverlay.h"
|
||||
|
||||
|
@ -6,6 +8,7 @@ Toggle::Toggle(QWidget *parent)
|
|||
: QAbstractButton(parent),
|
||||
_overlay(new RippleOverlay(this))
|
||||
{
|
||||
qDebug() << "1";
|
||||
}
|
||||
|
||||
Toggle::~Toggle()
|
||||
|
@ -15,5 +18,17 @@ Toggle::~Toggle()
|
|||
void Toggle::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
qDebug() << "2";
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
QPen pen;
|
||||
pen.setColor(Qt::black);
|
||||
pen.setWidth(2);
|
||||
painter.setPen(pen);
|
||||
|
||||
painter.drawRect(rect());
|
||||
|
||||
painter.drawRect(QRect(10, 10, 30, 30));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ public:
|
|||
explicit Toggle(QWidget *parent = 0);
|
||||
~Toggle();
|
||||
|
||||
QSize sizeHint() const { return QSize(32, 32); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue