-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImageBox.cpp
42 lines (33 loc) · 944 Bytes
/
ImageBox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Created by zjh_3 on 2023/7/27.
//
#include "ImageBox.h"
Flare::ImageBox::ImageBox(QWidget *parent) : Widget(parent), imageSize(0, 0), boxImage(QImage()) {
}
Flare::ImageBox::ImageBox(const QImage &image, QWidget *parent) : ImageBox(parent) {
boxImage = image;
}
void Flare::ImageBox::paintEvent(QPaintEvent *event) {
Widget::paintEvent(event);
QPainter painter(this);
painter.drawImage(
QRect(QPoint(size().width() / 2 - imageSize.width() / 2,
size().height() / 2 - imageSize.height() / 2),
imageSize), boxImage);
painter.end();
}
void Flare::ImageBox::setImageSize(const QSize &size) {
imageSize = size;
}
QSize Flare::ImageBox::ImageSize() {
return imageSize;
}
void Flare::ImageBox::setImage(const QImage &image) {
boxImage = image;
if (isVisible()) {
update();
}
}
QImage Flare::ImageBox::Image() {
return boxImage;
}