diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/imagelabel.cpp	Mon Mar 23 19:10:01 2015 +0100
@@ -0,0 +1,28 @@
+#include "imagelabel.h"
+
+ImageLabel::ImageLabel(QWidget *parent) :
+    QWidget(parent) {
+    label = new QLabel(this);
+    label->setScaledContents(true);
+    label->setFixedSize(0,0);
+}
+
+void ImageLabel::resizeEvent(QResizeEvent *event) {
+    QWidget::resizeEvent(event);
+    resizeImage();
+}
+
+const QPixmap* ImageLabel::pixmap() const {
+    return label->pixmap();
+}
+
+void ImageLabel::setPixmap (const QPixmap &pixmap){
+    label->setPixmap(pixmap);
+    resizeImage();
+}
+
+void ImageLabel::resizeImage() {
+    QSize pixSize = label->pixmap()->size();
+    pixSize.scale(size(), Qt::KeepAspectRatio);
+    label->setFixedSize(pixSize);
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)