QGIS API Documentation
4.3.0-Master (1c7cf7431bd)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
#include <QString>
19
20
using namespace
Qt::StringLiterals;
21
22
QString
QgsMargins::toString
()
const
23
{
24
if
(
isNull
() )
25
return
QString();
26
else
27
return
u
"%1,%2,%3,%4"
_s.arg(
qgsDoubleToString
( mLeft ),
qgsDoubleToString
( mTop ),
qgsDoubleToString
( mRight ),
qgsDoubleToString
( mBottom ) );
28
}
29
30
QgsMargins
QgsMargins::fromString
(
const
QString &
string
)
31
{
32
const
QStringList margins =
string
.split(
','
);
33
if
( margins.count() != 4 )
34
return
QgsMargins
();
35
36
return
QgsMargins
( margins.at( 0 ).toDouble(), margins.at( 1 ).toDouble(), margins.at( 2 ).toDouble(), margins.at( 3 ).toDouble() );
37
}
QgsMargins::QgsMargins
QgsMargins()=default
Constructs a margins object with all margins set to 0.
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:30
QgsMargins::isNull
bool isNull() const
Returns true if all margins are is 0; otherwise returns false.
Definition
qgsmargins.h:64
QgsMargins::toString
QString toString() const
Returns the margins encoded to a string.
Definition
qgsmargins.cpp:22
qgsDoubleToString
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition
qgis.h:7650
qgsmargins.h
Generated on
for QGIS API Documentation by
1.17.0