#include <ModelAPI_AttributeString.h>
#include <QLabel>
+#include <QEvent>
ModuleBase_WidgetErrorLabel::ModuleBase_WidgetErrorLabel(QWidget* theParent,
const Config_WidgetAPI* theData,
: ModuleBase_WidgetLabel(theParent, theData, theParentId)
{
myDefaultStyle = myLabel->styleSheet();
+ myLabel->setContentsMargins(0,0,0,4);
+ myLabel->setWordWrap(true);
+ myLabel->installEventFilter(this);
}
ModuleBase_WidgetErrorLabel::~ModuleBase_WidgetErrorLabel()
myLabel->setStyleSheet(myDefaultStyle);
} else {
myLabel->setText(aMsg.c_str());
- myLabel->setStyleSheet("QLabel { background-color : red; color : white; }");
+ //myLabel->setStyleSheet("QLabel { color : red; font : italic }");
+ myLabel->setStyleSheet("QLabel { color : red; font : bold }");
+ //myLabel->setStyleSheet("QLabel { border: 1px solid red; }");
}
return true;
}
+
+
+bool ModuleBase_WidgetErrorLabel::focusTo()
+{
+ restoreValue();
+ return false;
+}
+
+bool ModuleBase_WidgetErrorLabel::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+ if (theObj == myLabel) {
+ if (theEvent->type() == QEvent::Show)
+ restoreValue();
+ }
+ return ModuleBase_WidgetLabel::eventFilter(theObj, theEvent);
+}
/// \param theData the widget configuation. The attribute of the model widget is obtained from
/// \param theParentId is Id of a parent of the current attribute
ModuleBase_WidgetErrorLabel(QWidget* theParent, const Config_WidgetAPI* theData,
- const std::string& theParentId);
+ const std::string & theParentId);
virtual ~ModuleBase_WidgetErrorLabel();
virtual bool restoreValueCustom();
+ virtual bool focusTo();
+
+protected:
+ bool eventFilter(QObject* theObj, QEvent* theEvent);
+
private:
QString myDefaultStyle;
};