添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
骑白马的菠萝
·
jquery confirm确认框 ...
·
1 月前
·
喝醉的葡萄酒
·
陕西省交通运输厅
·
4 月前
·
稳重的葫芦
·
Using DDMS | Android ...
·
8 月前
·
一直单身的麻辣香锅
·
229637 – Expected an ...
·
9 月前
·
胆小的排球
·
暴力伤医,不仅要受到法律严惩还应被全社会唾弃 ...
·
1 年前
·
link管理
›
OctoBTT/customdialog.cpp at master · bigtreetech/OctoBTT · GitHub
https://github.com/bigtreetech/OctoBTT/blob/master/customdialog.cpp
跑龙套的小狗
2 天前
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Files
master
Breadcrumbs
OctoBTT
/
customdialog.cpp
Blame
Blame
Latest commit
History
History
147 lines (122 loc) · 4.8 KB
master
Breadcrumbs
OctoBTT
/
customdialog.cpp
Top
File metadata and controls
Code
Blame
147 lines (122 loc) · 4.8 KB
Raw
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#includ
e
"customdialog.
h
"
//
/ windowName:窗体标题
//
/ windowIcon:窗体标识图片路径
//
/ buttonName:按键水平布局---纯按键(垂直布局)
//
/ textContent:文本垂直布局
void
CustomDialog::showCustomDialog
(QString windowName, QString windowIcon, QStringList buttonName, QString textContent, QWidget *parent)
{
//
传参
_WindowName = windowName;
_WindowIcon = windowIcon;
_ButtonName = buttonName;
_TextContent = textContent;
_Parent = parent;
//
背景颜色
this
->
setWindowOpacity
(
0.9
);
//
透明度
this
->
setStyleSheet
(
"
background-color: rgba(128, 128, 128, 25%)
"
);
//
背景
//
设置窗口的标题和标识
this
->
setWindowTitle
(_WindowName);
this
->
setWindowIcon
(
QIcon
(_WindowIcon));
//
适应屏幕大小
this
->
resize
(_Parent->
width
()*
0.9
,_Parent->
height
()*
0.9
);
this
->
setFixedSize
(_Parent->
width
()*
0.9
,_Parent->
height
()*
0.9
);
//
使弹窗居中显示
this
->
move
(_Parent->
pos
().
x
() + (_Parent->
width
() -
this
->
width
()) /
2
,_Parent->
pos
().
y
() + (_Parent->
height
() -
this
->
height
()) /
2
);
//
设置文本显示
QTextBrowser textBrowser;
textBrowser.
setStyleSheet
(
"
border: none; color: rgb(245, 246, 255);background-color: rgba(128, 128, 128, 0%);
"
);
textBrowser.
setText
(_TextContent);
textBrowser.
setFixedSize
(_Parent->
width
()*
0.877
,_Parent->
height
()*
0.5
);
//
textBrowser.move();
//
textBrowser.setGeometry(50,50,_Parent->width()*800*0.8,_Parent->height()*480*0.5);
textBrowser.
setAlignment
(Qt::AlignCenter);
//
根据QStringList buttonName创建按键
QList<QPushButton*> btn;
for
(
int
i =
0
;i < _ButtonName.
count
() ;i++)
{
btn.
append
(
new
QPushButton
(_ButtonName[i]));
btn[i] =
new
QPushButton
(_ButtonName[i]);
//
指定按键样式
btn[i]->
setWhatsThis
(
"
BTStyleSheet
"
);
//
调整字体大小
QFont _font = btn[i]->
font
();
_font.
setPointSize
(_Parent->
maximumWidth
() > _Parent->
maximumHeight
() ? (
int
)_Parent->
maximumHeight
()/
30
: (
int
)_Parent->
maximumWidth
()/
30
);
btn[i]->
setFont
(_font);
textBrowser.
setFont
(_font);
}
//
调整按键和文本的位置
//
文本垂直布局
QVBoxLayout
VLayout
(
this
);
VLayout.
addSpacing
(
150
);
VLayout.
addWidget
(&textBrowser);
VLayout.
addSpacing
(
300
);
//
按键水平布局
QHBoxLayout RestartBT;
foreach
(QPushButton *item , btn)
{
RestartBT.
addWidget
(item);
//
按键信号连接槽
QObject::connect
(item, &QPushButton::clicked,
this
,[=]()
{
QPushButton *optBtn = qobject_cast<QPushButton *>(
sender
());
emit
OutputEvent
(optBtn->
text
());
this
->
close
();
});
}
VLayout.
addLayout
(&RestartBT);
//
模态显示
this
->
exec
();
}
void
CustomDialog::showCustomDialog
(QString windowName, QString windowIcon, QStringList buttonName, QWidget *parent)
{
//
传参
_WindowName = windowName;
_WindowIcon = windowIcon;
_ButtonName = buttonName;
_Parent = parent;
//
背景颜色
this
->
setWindowOpacity
(
0.9
);
//
透明度
this
->
setStyleSheet
(
"
background-color: rgba(128, 128, 128, 25%)
"
);
//
背景
//
设置窗口的标题和标识
this
->
setWindowTitle
(_WindowName);
this
->
setWindowIcon
(
QIcon
(_WindowIcon));
//
适应屏幕大小
this
->
resize
(_Parent->
width
()*
0.9
,_Parent->
height
()*
0.9
);
this
->
setFixedSize
(_Parent->
width
()*
0.9
,_Parent->
height
()*
0.9
);
//
使弹窗居中显示
this
->
move
(_Parent->
pos
().
x
() + (_Parent->
width
() -
this
->
width
()) /
2
,_Parent->
pos
().
y
() + (_Parent->
height
() -
this
->
height
()) /
2
);
//
根据QStringList buttonName创建按键
QList<QPushButton*> btn;
for
(
int
i =
0
;i < _ButtonName.
count
() ;i++)
{
btn.
append
(
new
QPushButton
(_ButtonName[i]));
btn[i] =
new
QPushButton
(_ButtonName[i]);
//
指定按键样式
btn[i]->
setWhatsThis
(
"
BTStyleSheet
"
);
//
调整字体大小
QFont _font = btn[i]->
font
();
_font.
setPointSize
(_Parent->
maximumWidth
() > _Parent->
maximumHeight
() ? (
int
)_Parent->
maximumHeight
()/
30
: (
int
)_Parent->
maximumWidth
()/
30
);
btn[i]->
setFont
(_font);
}
//
调整按键的位置
QVBoxLayout
VLayout
(
this
);
//
按键水平布局
foreach
(QPushButton *item , btn)
{
VLayout.
addWidget
(item);
//
按键信号连接槽
QObject::connect
(item, &QPushButton::clicked,
this
,[=]()
{
QPushButton *optBtn = qobject_cast<QPushButton *>(
sender
());
emit
OutputEvent
(optBtn->
text
());
this
->
close
();
});
}
//
模态显示
this
->
exec
();
}
void
CustomDialog::showCustomDialog
(QString windowName, QString windowIcon, QString textContent, QWidget *parent)
{
QStringList btnName = {
"
Ok
"
};
showCustomDialog
(windowName, windowIcon, btnName, textContent, parent);
}
推荐文章
骑白马的菠萝
·
jquery confirm确认框 无显示_mob64ca12d1a59e的技术博客_51CTO博客
1 月前
喝醉的葡萄酒
·
陕西省交通运输厅
4 月前
稳重的葫芦
·
Using DDMS | Android Developers
8 月前
一直单身的麻辣香锅
·
229637 – Expected an operand but found error
9 月前
胆小的排球
·
暴力伤医,不仅要受到法律严惩还应被全社会唾弃 - 中华人民共和国国防部
1 年前