QGIS API Documentation
3.40.0-Bratislava (b56115d8743)
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
z
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
w
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Related Symbols
3
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
Files
File List
File Members
All
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Variables
a
b
c
d
e
f
g
h
i
l
n
o
p
q
r
s
t
u
w
Typedefs
3
a
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
Enumerator
Macros
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
w
x
y
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
src
gui
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
19
QgsPixmapLabel::QgsPixmapLabel
( QWidget *parent )
20
: QLabel( parent )
21
{
22
}
19
QgsPixmapLabel::QgsPixmapLabel
( QWidget *parent ) {
…
}
23
24
void
QgsPixmapLabel::setPixmap
(
const
QPixmap &p )
25
{
26
const
bool
sizeChanged = ( p.size() != mPixmap.size() );
27
mPixmap = p;
28
29
if
( mPixmap.isNull() )
30
this->setMinimumHeight( 0 );
31
else
32
this->setMinimumHeight( PIXMAP_MINIMUM_HEIGHT );
33
34
if
( sizeChanged )
35
{
36
updateGeometry();
37
}
38
39
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
40
}
24
void
QgsPixmapLabel::setPixmap
(
const
QPixmap &p ) {
…
}
41
42
int
QgsPixmapLabel::heightForWidth
(
int
width )
const
43
{
44
if
( mPixmap.isNull() )
45
return
0;
46
47
return
( ( qreal )mPixmap.height() * width ) / mPixmap.width();
48
}
42
int
QgsPixmapLabel::heightForWidth
(
int
width )
const
{
…
}
49
50
QSize
QgsPixmapLabel::sizeHint
()
const
51
{
52
if
( mPixmap.isNull() )
53
return
QSize( 0, 0 );
54
55
const
int
w = this->width();
56
return
QSize( w,
heightForWidth
( w ) );
57
}
50
QSize
QgsPixmapLabel::sizeHint
()
const
{
…
}
58
59
void
QgsPixmapLabel::resizeEvent
( QResizeEvent *e )
60
{
61
QLabel::resizeEvent( e );
62
if
( !mPixmap.isNull() )
63
{
64
// Avoid infinite resize loop by setting a pixmap that'll always have a width and height less or equal to the label size
65
QLabel::setPixmap( mPixmap.scaled( this->size() -= QSize( 1, 1 ), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
66
}
67
}
59
void
QgsPixmapLabel::resizeEvent
( QResizeEvent *e ) {
…
}
68
69
void
QgsPixmapLabel::clear
()
70
{
71
mPixmap = QPixmap();
72
QLabel::clear();
73
this->setMinimumHeight( 0 );
74
}
69
void
QgsPixmapLabel::clear
() {
…
}
QgsPixmapLabel::clear
void clear()
Clears any label contents.
Definition
qgspixmaplabel.cpp:69
QgsPixmapLabel::heightForWidth
int heightForWidth(int width) const override
Calculates the height for the given width.
Definition
qgspixmaplabel.cpp:42
QgsPixmapLabel::sizeHint
QSize sizeHint() const override
An optimal size for the widget.
Definition
qgspixmaplabel.cpp:50
QgsPixmapLabel::resizeEvent
void resizeEvent(QResizeEvent *) override
Definition
qgspixmaplabel.cpp:59
QgsPixmapLabel::setPixmap
void setPixmap(const QPixmap &)
Definition
qgspixmaplabel.cpp:24
QgsPixmapLabel::QgsPixmapLabel
QgsPixmapLabel(QWidget *parent=nullptr)
Constructor for QgsPixmapLabel.
Definition
qgspixmaplabel.cpp:19
qgspixmaplabel.h
Generated on Mon Oct 28 2024 22:06:03 for QGIS API Documentation by
1.9.8