QT版本:5.12.9,已装VirtualKeyboard插件
我的main.qml类似如下,
重点是这三个部分:
z,怕不保险可以设置99
parent: Overlay.overlay //很关键,直接照着复制
focus:也不一定要用true,可以自己设置状态变化来改变
z: 1
parent: Overlay.overlay
focus: true
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.VirtualKeyboard 2.4
import QtQuick.Controls 2.5
import QtGraphicalEffects 1.12
Window {
id: window
visible: true
width: SCREEN_WIDTH
height: SCREEN_HEIGHT
Item {
id: itemMain
rotation: IS_ARM ? 90 : 0
width: IS_ARM ? parent.height : parent.width
height: IS_ARM ? parent.width : parent.height
InputPanel {
id: inputPanel
width: parent.width
z: 99
// z:1
y:parent.height
//不加这句话,键盘会被popup挡住
parent: Overlay.overlay
states: State {
name: "visible"
when: inputPanel.active
PropertyChanges {
target: inputPanel
y: itemMain.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration: 250
easing.type: Easing.InOutQuad
}
}
}
}
}
}
然后我的子页面里有个Popup,属性设置大概如下:
重点就是:
modal:false //模态必须为false,允许其他控件作用
modal: false
focus: true
Popup {
id: ipPopup
anchors.centerIn: parent
width: parent.width-70
height: parent.height/4*3
modal: false
focus: true
closePolicy: "NoAutoClose"
background:Rectangle{
anchors.fill: parent
border.color: "#1DEDD7"
border.width: 2
radius:5
gradient: Gradient {
GradientStop { position: 0.0; color: "#103D2C" }
GradientStop { position: 1.0; color: "#071F14" }
}
Image {
source: "../images/setup/USBPopupbg.png"
width: parent.width
height: 160
anchors.bottom: parent.bottom
}
Button{
id:btnClose
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: 8
width: 30
height: 30
background: Rectangle{
color: "transparent"
Image{
source: "qrc:/images/setup/USBPopupbg10.png"
anchors.fill: parent
}
}
onClicked: ipPopup.close()
}
}
Text {
id:ipTitle
text: "IP设置"
font.pixelSize: 32
font.family: "SourceHanSansCN-Bold"
color: "#FFFFFF"
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 60
horizontalAlignment: Text.AlignHCenter
}
Text {
id: currentAddress
text: qsTr("当前地址:")
anchors.top: ipTitle.bottom
anchors.topMargin: ipTitle.height*2
anchors.left: parent.left
anchors.leftMargin: 90
color: "white"
font.pixelSize: 24
font.family: "SourceHanSansCN-Regular"
}
Rectangle{
id:currentAddressValue
width: 370
color: "transparent"
anchors.verticalCenter: currentAddress.verticalCenter
anchors.left: currentAddress.right
anchors.leftMargin: 5
Image{
source: "qrc:/images/setup/组 17.png"
anchors.fill: parent
}
Text{
text: "192.168.1.1"
anchors.left: parent.left
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
color: "white"
font.pixelSize: 24
font.family: "SourceHanSansCN-Regular"
}
}
Text {
id: dhcp
text: qsTr("DHCP配置:")
anchors.top: currentAddress.bottom
anchors.topMargin: 70
anchors.right: currentAddress.right
color: "white"
font.pixelSize: 24
font.family: "SourceHanSansCN-Regular"
}
Row{
anchors.verticalCenter: dhcp.verticalCenter
anchors.left: dhcp.right
anchors.leftMargin: 5
RadioButton{
checked:true
text: qsTr("启用")
}
RadioButton{
checked:false
text: qsTr("关闭")
}
}
Text {
id: ipAddress
text: qsTr("IP地址:")
anchors.top: dhcp.bottom
anchors.topMargin: 70
anchors.right: currentAddress.right
color: "white"
font.pixelSize: 24
font.family: "SourceHanSansCN-Regular"
}
TextField{
id:ipAddressInput
width: 370
height: 55
placeholderText: "请输入"
placeholderTextColor: "white"
font.pixelSize: 20
font.bold: true
color: "white"
anchors.left: ipAddress.right
anchors.leftMargin: 5
anchors.verticalCenter: ipAddress.verticalCenter
maximumLength: 40
horizontalAlignment: "AlignLeft"
background: Image {
source: "qrc:/images/setup/组 17.png"
}
}
}