From 8aef67d661aa1fcf3f952cef1219bca431cc9f99 Mon Sep 17 00:00:00 2001 From: laserpants Date: Sat, 18 Jun 2016 12:36:40 +0300 Subject: [PATCH] implement paint event handler --- components/circularprogress.cpp | 8 ++++++++ components/circularprogress.h | 2 ++ components/progress.cpp | 8 ++++++++ components/progress.h | 2 ++ examples/appbarexamples.cpp | 17 +++++++++++++++++ 5 files changed, 37 insertions(+) diff --git a/components/circularprogress.cpp b/components/circularprogress.cpp index ceab303..b0145d4 100644 --- a/components/circularprogress.cpp +++ b/components/circularprogress.cpp @@ -1,4 +1,5 @@ #include "circularprogress.h" +#include #include "circularprogress_p.h" CircularProgressPrivate::CircularProgressPrivate(CircularProgress *q) @@ -24,3 +25,10 @@ CircularProgress::CircularProgress(QWidget *parent) CircularProgress::~CircularProgress() { } + +void CircularProgress::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + + painter.drawRect(rect()); +} diff --git a/components/circularprogress.h b/components/circularprogress.h index fd7ba7d..dd7754e 100644 --- a/components/circularprogress.h +++ b/components/circularprogress.h @@ -14,6 +14,8 @@ public: ~CircularProgress(); protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + const QScopedPointer d_ptr; private: diff --git a/components/progress.cpp b/components/progress.cpp index 13364b5..647faf6 100644 --- a/components/progress.cpp +++ b/components/progress.cpp @@ -1,4 +1,5 @@ #include "progress.h" +#include #include "progress_p.h" ProgressPrivate::ProgressPrivate(Progress *q) @@ -24,3 +25,10 @@ Progress::Progress(QWidget *parent) Progress::~Progress() { } + +void Progress::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + + painter.drawRect(rect()); +} diff --git a/components/progress.h b/components/progress.h index 7b88da3..2915ea0 100644 --- a/components/progress.h +++ b/components/progress.h @@ -14,6 +14,8 @@ public: ~Progress(); protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + const QScopedPointer d_ptr; private: diff --git a/examples/appbarexamples.cpp b/examples/appbarexamples.cpp index a8c5417..37400ac 100644 --- a/examples/appbarexamples.cpp +++ b/examples/appbarexamples.cpp @@ -2,6 +2,7 @@ #include "appbarexamples.h" #include "components/appbar.h" #include "frame.h" +#include "components/progress.h" AppBarExamples::AppBarExamples(QWidget *parent) : ExampleList(parent) @@ -34,6 +35,22 @@ AppBarExamples::AppBarExamples(QWidget *parent) ); frame->setWidget(area); + mainLayout->addWidget(frame); + } + { + QWidget *widget = new QWidget; + QVBoxLayout *layout = new QVBoxLayout; + + widget->setLayout(layout); + + Progress *p = new Progress; + + Frame *frame = new Frame; + frame->setCodeSnippet( + "" + ); + frame->setWidget(p); + mainLayout->addWidget(frame); } }