Mercurial > retraceit
comparison src/imagelabel.cpp @ 3:248d5d1cdb38
Add functionalty to control buttons and make picture resizable
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 23 Mar 2015 19:10:01 +0100 |
parents | |
children | 6b9b5efcd7f4 |
comparison
equal
deleted
inserted
replaced
2:97d2c8869c39 | 3:248d5d1cdb38 |
---|---|
1 #include "imagelabel.h" | |
2 | |
3 ImageLabel::ImageLabel(QWidget *parent) : | |
4 QWidget(parent) { | |
5 label = new QLabel(this); | |
6 label->setScaledContents(true); | |
7 label->setFixedSize(0,0); | |
8 } | |
9 | |
10 void ImageLabel::resizeEvent(QResizeEvent *event) { | |
11 QWidget::resizeEvent(event); | |
12 resizeImage(); | |
13 } | |
14 | |
15 const QPixmap* ImageLabel::pixmap() const { | |
16 return label->pixmap(); | |
17 } | |
18 | |
19 void ImageLabel::setPixmap (const QPixmap &pixmap){ | |
20 label->setPixmap(pixmap); | |
21 resizeImage(); | |
22 } | |
23 | |
24 void ImageLabel::resizeImage() { | |
25 QSize pixSize = label->pixmap()->size(); | |
26 pixSize.scale(size(), Qt::KeepAspectRatio); | |
27 label->setFixedSize(pixSize); | |
28 } |