-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinfowidget.cpp
67 lines (57 loc) · 1.48 KB
/
infowidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "infowidget.h"
InfoWidget::InfoWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
//更新HarmonyOS字体
QFont font;
int font_Id = QFontDatabase::addApplicationFont(":/src/font/HarmonyOS_Sans_SC_Regular.ttf");
QStringList fontName = QFontDatabase::applicationFontFamilies(font_Id);
font.setFamily(fontName.at(0));
auto listWidget = findChildren<QWidget*>();
for (auto& widget : listWidget) //遍历所有组件
{
font.setWeight(widget->font().weight());
font.setPointSize(widget->font().pointSize());
widget->setFont(font);
}
//背景透明
QPalette pal = ui.textBrowser_info->palette();
pal.setBrush(QPalette::Base, QBrush(QColor(255, 0, 0, 0)));
ui.textBrowser_info->setPalette(pal);
}
InfoWidget::~InfoWidget()
{
}
void InfoWidget::setInfo(const QString& info)
{
ui.textBrowser_info->setText(info);
//ui.textBrowser_info->adjustSize();
//this->adjustSize(); //自动调整大小
}
void InfoWidget::setInfoTitle(const QString& title)
{
ui.label_infoType->setText(title);
}
void InfoWidget::setInfoIcon(const QPixmap& icon)
{
ui.label_icon->setPixmap(icon);
}
void InfoWidget::setBoxTitle(const QString& title)
{
ui.groupBox->setTitle(title);
}
void InfoWidget::on_btn_ok_clicked()
{
this->close();
}
void InfoWidget::keyPressEvent(QKeyEvent* event)
{
switch (event->key())
{
case Qt::Key_Escape:
this->close(); break;
default:
QWidget::keyPressEvent(event);
}
}