/
ImageBlock.cpp
66 lines (54 loc) · 1.29 KB
/
ImageBlock.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "ImageBlock.h"
#include <QVBoxLayout>
#include <QPalette>
#include <QDebug>
ImageBlock::ImageBlock(QWidget* parent)
:QGroupBox(parent)
{
init();
}
ImageBlock::ImageBlock(const QString& title, QWidget* parent)
:QGroupBox(title, parent)
{
init();
}
QLabel *ImageBlock::image()
{
return image_;
}
ScrollText *ImageBlock::title()
{
return title_;
}
void ImageBlock::setTitle(const QString& title){
title_->setText(title);
}
void ImageBlock::setImage(const QString& path){
image_->setPixmap(QPixmap(path));
}
void ImageBlock::setImage(const QPixmap &pic)
{
image_->setPixmap(pic);
}
void ImageBlock::setSize(const int width, const int height)
{
image_->setPixmap(image_->pixmap()->scaled(width, height));
}
void ImageBlock::mousePressEvent(QMouseEvent *event)
{
emit clicked();
QGroupBox::mouseReleaseEvent(event);
}
void ImageBlock::init(){
title_ = new ScrollText();
image_ = new QLabel();
setImage(":/buttons/musical-note.svg");
setTitle("Title");
QVBoxLayout* grid = new QVBoxLayout();
grid->addWidget(image_);
grid->addWidget(title_);
title_->setFixedWidth(100);
title_->setStyleSheet("border-color:white; color:rgba(114,136,125,1);");
grid->setSizeConstraint(QLayout::SetFixedSize);
setLayout(grid);
}