WebEngine Widgets WebUI Example▲
Sélectionnez
&
lt;!
DOCTYPE html&
gt;
&
lt;html&
gt;
&
lt;head&
gt;
&
lt;title&
gt;Qt WebEngine WebUI Example&
lt;/
title&
gt;
&
lt;style&
gt;
html {
background
:
#f0f0f0;
color
:
#303030
;
font
:
16
px system-
ui;
height
:
100
%
;
}
body {
margin
:
0
;
padding
:
0
;
height
:
100
%
;
display
:
flex;
flex-
direction: column;
align-
items: stretch;
}
body &
gt; *
{
padding-
left: 20
px;
padding-
right: 20
px;
}
header {
flex
:
none;
display
:
flex;
align-
items: center;
background
:
#f0fff0;
border-
bottom: 1
px solid #e0e0e0;
padding-
top: 20
px;
padding-
bottom: 20
px;
}
header &
gt; h1 {
font
:
bold 20
px system-
ui;
margin-
left: 18
px;
}
main {
flex
:
auto
;
}
footer {
flex
:
none;
display
:
flex;
justify-
content: center;
padding-
bottom: 20
px;
}
button {
background
:
#41
cd52;
color
:
#f0f0f0;
font
:
16
px system-
ui;
border
:
0
;
box-
shadow: 0
px 1
px 3
px rgb(0
,0
,0
,0.5
);
cursor
:
pointer;
margin
:
0
0
1
px;
padding
:
10
px 24
px;
}
button
:
hover {
background
:
#50
dc61;
}
button
:
active {
background
:
#50
dc61;
box-
shadow: 0
px 1
px 2
px rgb(0
,0
,0
,0.5
);
margin
:
1
px 0
0
;
}
button
:
focus {
outline
:
0
;
}
&
lt;/
style&
gt;
&
lt;/
head&
gt;
&
lt;body&
gt;
&
lt;header&
gt;
&
lt;img width=
"48px"
height=
"48px"
src=
"qrc:/qt-project.org/qmessagebox/images/qtlogo-64.png"
&
gt;
&
lt;h1&
gt;WebEngine Widgets&
lt;br&
gt;WebUI Example&
lt;/
h1&
gt;
&
lt;/
header&
gt;
&
lt;main&
gt;
&
lt;p&
gt;
Aside from the built-
in schemes, such as &
lt;code&
gt;http&
lt;/
code&
gt; and
&
lt;code&
gt;qrc&
lt;/
code&
gt;, Qt WebEngine may be extended with &
lt;em&
gt;custom
schemes&
lt;/
em&
gt; by creating &
lt;em&
gt;custom scheme handlers&
lt;/
em&
gt;.
&
lt;/
p&
gt;
&
lt;p&
gt;
This is a simple HTML page loaded from a custom scheme and
displayed by a &
lt;code&
gt;QWebEngineView&
lt;/
code&
gt;. Even the Quit button
below is a standard HTML &
lt;code&
gt;&
amp;lt;button&
amp;gt;&
lt;/
code&
gt; element.
&
lt;/
p&
gt;
&
lt;p&
gt;
Read the documentation to find out
&
lt;/
p&
gt;
&
lt;ul&
gt;
&
lt;li&
gt;
&
lt;p&
gt;
How to create a custom scheme handler which serves HTML
and
handles HTML form submissions.
&
lt;/
p&
gt;
&
lt;/
li&
gt;
&
lt;li&
gt;
&
lt;p&
gt;
How to prevent ordinary web content from accessing the
custom scheme.
&
lt;/
p&
gt;
&
lt;/
li&
gt;
&
lt;li&
gt;
&
lt;p&
gt;
How to prevent any other scheme from submitting HTML
form data.
&
lt;/
p&
gt;
&
lt;/
li&
gt;
&
lt;/
ul&
gt;
&
lt;/
main&
gt;
&
lt;footer&
gt;
&
lt;form action=
""
method=
"post"
&
gt;
&
lt;button name=
"quit"
&
gt;Quit&
lt;/
button&
gt;
&
lt;/
form&
gt;
&
lt;/
footer&
gt;
&
lt;/
body&
gt;
&
lt;/
html&
gt;