QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsludialog.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsludialog.cpp - description
3
-------------------
4
begin : September 2004
5
copyright : (C) 2004 by Marco Hugentobler
6
email : marco.hugentobler@autoform.ch
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsludialog.h
"
19
20
#include "moc_qgsludialog.cpp"
21
22
QgsLUDialog::QgsLUDialog
( QWidget *parent, Qt::WindowFlags fl )
23
: QDialog( parent, fl )
24
{
25
setupUi(
this
);
26
27
connect( mLowerEdit, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this
, [
this
](
double
value ) { setDecimalPlaces( mLowerEdit, value ); } );
28
connect( mUpperEdit, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this
, [
this
](
double
value ) { setDecimalPlaces( mUpperEdit, value ); } );
29
}
30
31
QString
QgsLUDialog::lowerValue
()
const
32
{
33
return
mLowerEdit->text();
34
}
35
36
double
QgsLUDialog::lowerValueDouble
()
const
37
{
38
return
mLowerEdit->value();
39
}
40
41
QString
QgsLUDialog::upperValue
()
const
42
{
43
return
mUpperEdit->text();
44
}
45
46
double
QgsLUDialog::upperValueDouble
()
const
47
{
48
return
mUpperEdit->value();
49
}
50
51
void
QgsLUDialog::setLowerValue
(
const
QString &val )
52
{
53
bool
ok;
54
const
double
value { QLocale().toDouble( val, &ok ) };
55
mLowerEdit->setValue( value );
56
if
( ok )
57
{
58
setDecimalPlaces( mLowerEdit, value );
59
}
60
}
61
62
void
QgsLUDialog::setUpperValue
(
const
QString &val )
63
{
64
bool
ok;
65
const
double
value { QLocale().toDouble( val, &ok ) };
66
mUpperEdit->setValue( value );
67
if
( ok )
68
{
69
setDecimalPlaces( mUpperEdit, value );
70
}
71
}
72
73
void
QgsLUDialog::setDecimalPlaces(
QgsDoubleSpinBox
*widget,
double
value )
const
74
{
75
const
QString strVal { QVariant( value ).toString() };
76
const
int
dotPosition( strVal.indexOf(
'.'
) );
77
int
decimals { 2 };
78
if
( dotPosition >= 0 )
79
{
80
decimals = std::max<int>( 2, strVal.length() - dotPosition - 1 );
81
widget->setDecimals( decimals );
82
}
83
}
QgsDoubleSpinBox
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
Definition
qgsdoublespinbox.h:46
QgsLUDialog::upperValue
QString upperValue() const
Definition
qgsludialog.cpp:41
QgsLUDialog::lowerValue
QString lowerValue() const
Definition
qgsludialog.cpp:31
QgsLUDialog::QgsLUDialog
QgsLUDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Definition
qgsludialog.cpp:22
QgsLUDialog::upperValueDouble
double upperValueDouble() const
Returns the upper value.
Definition
qgsludialog.cpp:46
QgsLUDialog::lowerValueDouble
double lowerValueDouble() const
Returns the lower value.
Definition
qgsludialog.cpp:36
QgsLUDialog::setLowerValue
void setLowerValue(const QString &val)
Definition
qgsludialog.cpp:51
QgsLUDialog::setUpperValue
void setUpperValue(const QString &val)
Definition
qgsludialog.cpp:62
qgsludialog.h
Generated on
for QGIS API Documentation by
1.17.0