QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
src
core
qgsmargins.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmargins.cpp
3
--------------
4
Date : January 2017
5
Copyright : (C) 2017 by Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
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 "
qgsmargins.h
"
17
18
QString
QgsMargins::toString
()
const
19
{
20
if
(
isNull
() )
21
return
QString();
22
else
23
return
QStringLiteral(
"%1,%2,%3,%4"
).arg(
qgsDoubleToString
( mLeft ),
qgsDoubleToString
( mTop ),
24
qgsDoubleToString
( mRight ),
qgsDoubleToString
( mBottom ) );
25
}
26
27
QgsMargins
QgsMargins::fromString
(
const
QString &
string
)
28
{
29
const
QStringList margins =
string
.split(
','
);
30
if
( margins.count() != 4 )
31
return
QgsMargins
();
32
33
return
QgsMargins
( margins.at( 0 ).toDouble(),
34
margins.at( 1 ).toDouble(),
35
margins.at( 2 ).toDouble(),
36
margins.at( 3 ).toDouble() );
37
}
qgsDoubleToString
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition:
qgis.h:2204
QgsMargins::fromString
static QgsMargins fromString(const QString &string)
Returns a QgsMargins object decoded from a string, or a null QgsMargins if the string could not be in...
Definition:
qgsmargins.cpp:27
QgsMargins::toString
QString toString() const
Returns the margins encoded to a string.
Definition:
qgsmargins.cpp:18
QgsMargins::isNull
bool isNull() const
Returns true if all margins are is 0; otherwise returns false.
Definition:
qgsmargins.h:63
QgsMargins
The QgsMargins class defines the four margins of a rectangle.
Definition:
qgsmargins.h:37
QgsMargins::QgsMargins
QgsMargins()=default
Constructs a margins object with all margins set to 0.
qgsmargins.h
Generated on Sun Sep 11 2022 00:03:17 for QGIS API Documentation by
1.8.17