QGIS API Documentation
3.43.0-Master (3ee7834ace6)
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
q
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
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
y
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
#include "moc_qgspixmaplabel.cpp"
18
19
20
QgsPixmapLabel::QgsPixmapLabel
( QWidget *parent )
21
: QLabel( parent )
22
{
23
}
20
QgsPixmapLabel::QgsPixmapLabel
( QWidget *parent ) {
…
}
24
25
void
QgsPixmapLabel::setPixmap
(
const
QPixmap &p )
26
{
27
const
bool
sizeChanged = ( p.size() != mPixmap.size() );
28
mPixmap = p;
29
30
if
( mPixmap.isNull() )
31
this->setMinimumHeight( 0 );
32
else
33
this->setMinimumHeight( PIXMAP_MINIMUM_HEIGHT );
34
35
if
( sizeChanged )
36
{
37
updateGeometry();
38
}
39
40
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
41
}
25
void
QgsPixmapLabel::setPixmap
(
const
QPixmap &p ) {
…
}
42
43
int
QgsPixmapLabel::heightForWidth
(
int
width )
const
44
{
45
if
( mPixmap.isNull() )
46
return
0;
47
48
return
( ( qreal ) mPixmap.height() * width ) / mPixmap.width();
49
}
43
int
QgsPixmapLabel::heightForWidth
(
int
width )
const
{
…
}
50
51
QSize
QgsPixmapLabel::sizeHint
()
const
52
{
53
if
( mPixmap.isNull() )
54
return
QSize( 0, 0 );
55
56
const
int
w = this->width();
57
return
QSize( w,
heightForWidth
( w ) );
58
}
51
QSize
QgsPixmapLabel::sizeHint
()
const
{
…
}
59
60
void
QgsPixmapLabel::resizeEvent
( QResizeEvent *e )
61
{
62
QLabel::resizeEvent( e );
63
if
( !mPixmap.isNull() )
64
{
65
// Avoid infinite resize loop by setting a pixmap that'll always have a width and height less or equal to the label size
66
QLabel::setPixmap( mPixmap.scaled( this->size() -= QSize( 1, 1 ), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
67
}
68
}
60
void
QgsPixmapLabel::resizeEvent
( QResizeEvent *e ) {
…
}
69
70
void
QgsPixmapLabel::clear
()
71
{
72
mPixmap = QPixmap();
73
QLabel::clear();
74
this->setMinimumHeight( 0 );
75
}
70
void
QgsPixmapLabel::clear
() {
…
}
QgsPixmapLabel::clear
void clear()
Clears any label contents.
Definition
qgspixmaplabel.cpp:70
QgsPixmapLabel::heightForWidth
int heightForWidth(int width) const override
Calculates the height for the given width.
Definition
qgspixmaplabel.cpp:43
QgsPixmapLabel::sizeHint
QSize sizeHint() const override
An optimal size for the widget.
Definition
qgspixmaplabel.cpp:51
QgsPixmapLabel::resizeEvent
void resizeEvent(QResizeEvent *) override
Definition
qgspixmaplabel.cpp:60
QgsPixmapLabel::setPixmap
void setPixmap(const QPixmap &)
Definition
qgspixmaplabel.cpp:25
QgsPixmapLabel::QgsPixmapLabel
QgsPixmapLabel(QWidget *parent=nullptr)
Constructor for QgsPixmapLabel.
Definition
qgspixmaplabel.cpp:20
qgspixmaplabel.h
Generated on Mon Mar 24 2025 21:55:38 for QGIS API Documentation by
1.9.8