kylin-music/UI/base/labedit.cpp

43 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "labedit.h"
#include <QRegExpValidator>
LabEdit::LabEdit()
{
init();
}
void LabEdit::init()
{
QHBoxLayout* mainLayout = new QHBoxLayout();
lab = new QLabel(this);
lab->setText(QString("%1").arg(leng));
mainLayout->addWidget(lab);
mainLayout->setAlignment(Qt::AlignRight);
this->setLayout(mainLayout);
// QRegExp rx = QRegExp("[^\\\\/:*?\"&<>|]*"); //限制以下特殊符号在lineEdit中的输入
// QRegExpValidator* validator = new QRegExpValidator(rx);
// this->setValidator(validator);
}
void LabEdit::setLabelNumber(int num)
{
lab->setText(QString("%1").arg(num));
if (num == 0) {
lab->setStyleSheet("QLabel{color:#F44E50;}");
} else {
lab->setStyleSheet("QLabel{color:#000000;}");
}
}
void LabEdit::slotLableSetFontSize(int size)
{
//默认大小12px,换算成pt为9
double lableBaseFontSize = PT_11;//魔鬼数字,自行处理
double nowFontSize = lableBaseFontSize * double(size) / 11;//11为系统默认大小魔鬼数字自行处理
QFont font;
font.setPointSizeF(nowFontSize);
lab->setFont(font);
}