From aed62e92417cd58184b2d03382e770ae700e99c5 Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Mon, 12 Sep 2016 08:57:13 +0200 Subject: [PATCH] Adding the ability to have an icon for the label. --- src/ModuleBase/ModuleBase_WidgetLabel.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.cpp b/src/ModuleBase/ModuleBase_WidgetLabel.cpp index bab0894cb..dc194ea2e 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLabel.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -21,10 +22,17 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent, : ModuleBase_ModelWidget(theParent, theData) { QString aText = QString::fromStdString(theData->getProperty("title")); - myLabel = new QLabel(aText, theParent); + QString aLabelIcon = QString::fromStdString(theData->getProperty("icon")); + + myLabel = new QLabel(aText, theParent); + if (!aLabelIcon.isEmpty()) { + myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon)); + myLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop); + } else { + myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); + } myLabel->setWordWrap(true); myLabel->setIndent(5); - myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); myLabel->setContentsMargins(0,0,0,4); QVBoxLayout* aLayout = new QVBoxLayout(this); -- 2.39.2