1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_IWorkshop.cpp
4 // Created: 30 Nov 2016
5 // Author: Natalia ERMOLAEVA
7 #include <ModuleBase_LabelValue.h>
8 #include <ModuleBase_IconFactory.h>
10 #include <QHBoxLayout>
14 ModuleBase_LabelValue::ModuleBase_LabelValue(QWidget* theParent, const QString& theText,
15 const QString& theToolTip, const QString& theIcon,
17 : QWidget(theParent), myPrecision(thePrecision), myValue(0)
19 QHBoxLayout* aLayout = new QHBoxLayout(this);
20 aLayout->setContentsMargins(2, 0, 0, 0);
21 aLayout->setSpacing(0);
23 myLabel = new QLabel(QString("%1 : ").arg(theText), this);
24 if (!theIcon.isEmpty()) {
25 myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(theIcon));
26 aLayout->setSpacing(4);
28 myLabel->setToolTip(!theToolTip.isEmpty() ? theToolTip : theText);
29 aLayout->addWidget(myLabel);
31 myLabelValue = new QLabel("", this);
32 aLayout->addWidget(myLabelValue, 1);
34 // VSR 01/07/2010: Disable thousands separator for spin box
35 // (to avoid inconsistency of double-2-string and string-2-double conversion)
37 loc.setNumberOptions(loc.numberOptions() |
38 QLocale::OmitGroupSeparator |
39 QLocale::RejectGroupSeparator);
42 aLayout->addStretch(1);
45 ModuleBase_LabelValue::~ModuleBase_LabelValue()
49 void ModuleBase_LabelValue::setValue(const double theValue)
53 QString aStrValue = locale().toString(theValue, myPrecision >= 0 ? 'f' : 'g', qAbs(myPrecision));
54 myLabelValue->setText(aStrValue);
55 myLabelValue->setToolTip(QString::number(theValue));