QGIS API Documentation  2.14.0-Essen
qgspixmaplabel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  ----------------------------------------------------
4  date : 7.9.2015
5  copyright : (C) 2015 by Matthias Kuhn
6  email : matthias (at) opengis.ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgspixmaplabel.h"
17 
18 
20  QLabel( parent )
21 {
22  this->setMinimumSize( 1, 1 );
23 }
24 
26 {
27  mPixmap = p;
28  QLabel::setPixmap( p );
29 }
30 
32 {
33  return (( qreal )mPixmap.height()*width ) / mPixmap.width();
34 }
35 
37 {
38  int w = this->width();
39  return QSize( w, heightForWidth( w ) );
40 }
41 
43 {
45  QLabel::setPixmap( mPixmap.scaled( this->size(),
46  Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
47 }
virtual QSize sizeHint() const override
An optimal size for the widget.
void setPixmap(const QPixmap &)
int width() const
void setPixmap(const QPixmap &)
virtual int heightForWidth(int width) const override
Calculates the height for the given width.
int width() const
void setMinimumSize(const QSize &)
QPixmap scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
int height() const
virtual void resizeEvent(QResizeEvent *event)
void resizeEvent(QResizeEvent *) override
QgsPixmapLabel(QWidget *parent=nullptr)