feat: Add ErrorLabel component.
This commit is contained in:
17
src/components/ErrorLabel.cpp
Normal file
17
src/components/ErrorLabel.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "ErrorLabel.h"
|
||||
|
||||
ErrorLabel::ErrorLabel(QWidget* aParent)
|
||||
: QLabel(aParent)
|
||||
{
|
||||
setObjectName("warn");
|
||||
setWordWrap(true);
|
||||
}
|
||||
|
||||
void ErrorLabel::setErrorText(const QString& aText)
|
||||
{
|
||||
QFont font = this->font();
|
||||
QFontMetrics metrics(font);
|
||||
int width = metrics.width(aText);
|
||||
this->setFixedHeight(metrics.lineSpacing() * (width / this->width()) + 30 );
|
||||
setText(aText);
|
||||
}
|
||||
14
src/components/ErrorLabel.h
Normal file
14
src/components/ErrorLabel.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ERRORLABEL_H
|
||||
#define ERRORLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class ErrorLabel : public QLabel
|
||||
{
|
||||
public:
|
||||
ErrorLabel(QWidget* aParent);
|
||||
|
||||
void setErrorText(const QString& aText);
|
||||
};
|
||||
|
||||
#endif // ERRORLABEL_H
|
||||
Reference in New Issue
Block a user