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>
9 #include <ModuleBase_Tools.h>
11 #include <QHBoxLayout>
15 ModuleBase_LabelValue::ModuleBase_LabelValue(QWidget* theParent, const QString& theText,
16 const QString& theToolTip, const QString& theIcon,
18 : QWidget(theParent), myPrecision(thePrecision), myValue(0)
20 QHBoxLayout* aLayout = new QHBoxLayout(this);
21 aLayout->setContentsMargins(2, 0, 0, 0);
22 aLayout->setSpacing(0);
24 myLabel = new QLabel(QString("%1 : ").arg(theText), this);
25 if (!theIcon.isEmpty()) {
26 myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(theIcon));
27 aLayout->setSpacing(4);
29 myLabel->setToolTip(!theToolTip.isEmpty() ? theToolTip : theText);
30 aLayout->addWidget(myLabel);
32 myLabelValue = new QLabel("", this);
33 aLayout->addWidget(myLabelValue, 1);
35 setLocale(ModuleBase_Tools::doubleLocale());
36 aLayout->addStretch(1);
39 ModuleBase_LabelValue::~ModuleBase_LabelValue()
43 void ModuleBase_LabelValue::setValue(const double theValue)
47 QString aStrValue = locale().toString(theValue, myPrecision >= 0 ? 'f' : 'g', qAbs(myPrecision));
48 myLabelValue->setText(aStrValue);
49 myLabelValue->setToolTip(aStrValue);