yhkylin-backup-tools/kybackup/component/linelabel.cpp

24 lines
567 B
C++

#include "linelabel.h"
#include <QPainter>
LineLabel::LineLabel(QWidget* parent /*= nullptr*/, QColor color /*= QColor(0xCC, 0xCC, 0xCC)*/, QSize size /*= QSize(150, 24)*/) :
QLabel(parent),
m_color(color)
{
setFixedSize(size);
}
LineLabel::~LineLabel()
{}
void LineLabel::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(m_color);
QRect rect = this->rect();
painter.drawLine(0, rect.height()/2, rect.width(), rect.height()/2);
QLabel::paintEvent(event);
}