qml虚拟键盘:keyboardDesignWidth和Height
qml virtual keyboard: keyboardDesignWidth and Height
我正在查看虚拟键盘的 QML 样式。 keyboardDesignWidth 和 Height 的用途是什么?我似乎在管理键盘的宽度和高度方面遇到了很多麻烦,并且永远无法将其设置为我想要的方式。直接设置 keyboardHeight 和 Width 也没有多大帮助。
问题是组件背景大小是以某种方式在幕后计算的。因此,即使我有键盘按钮和我想要的大小,无关的背景也会覆盖我的一些其他控件,并且很难对键盘的大小进行细粒度控制。
直接控制虚拟键盘的宽度和大小的正确方法是什么?
The keyboard size is automatically calculated from the available width; that is, the keyboard maintains the aspect ratio specified by the current style. Therefore the application should only set the width and y coordinates of the InputPanel, and not the height.
所以如果你想有一个特定的高度,你需要相应地设置宽度。
What is the right way to control the width and size of the virtual keyboard directly?
例如
InputPanel {
anchors.fill: parent
anchors.leftMargin: 100
anchors.rightMargin: 100
}
例如
InputPanel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
width: 30
}
那么 keyboardDesignHeight/Width
是怎么回事?好吧,这似乎是键盘的尺寸,当不需要缩放它时:
scaleHint : real
The keyboard style scale hint. This value is determined by dividing keyboardHeight
by keyboardDesignHeight
. All pixel dimensions must be proportional to this value.
This property is readonly!
所以设置这些不会禁用输入面板根据宽度自动调整大小。
您可能会使用它们来计算比率,并据此设置宽度以达到您想要的高度。
也许这个例子可以帮助你理解这个属性:
import QtQuick 2.6
import QtQuick.Window 2.0
import QtQuick.Controls 2.0
import QtQuick.VirtualKeyboard 2.0
ApplicationWindow {
id:appwindow
visible: true
width: 800
height: 600
title: qsTr("Test")
InputPanel {
id: ip
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
width: 800
Component.onCompleted: console.log(Object.keys(ip.keyboard.style).sort())
}
Slider {
id: sl
from: 0
to: 3000
}
Binding {
target: ip.keyboard.style
property: 'keyboardDesignHeight'
value: sl.value
}
}
我正在查看虚拟键盘的 QML 样式。 keyboardDesignWidth 和 Height 的用途是什么?我似乎在管理键盘的宽度和高度方面遇到了很多麻烦,并且永远无法将其设置为我想要的方式。直接设置 keyboardHeight 和 Width 也没有多大帮助。
问题是组件背景大小是以某种方式在幕后计算的。因此,即使我有键盘按钮和我想要的大小,无关的背景也会覆盖我的一些其他控件,并且很难对键盘的大小进行细粒度控制。
直接控制虚拟键盘的宽度和大小的正确方法是什么?
The keyboard size is automatically calculated from the available width; that is, the keyboard maintains the aspect ratio specified by the current style. Therefore the application should only set the width and y coordinates of the InputPanel, and not the height.
所以如果你想有一个特定的高度,你需要相应地设置宽度。
What is the right way to control the width and size of the virtual keyboard directly?
例如
InputPanel {
anchors.fill: parent
anchors.leftMargin: 100
anchors.rightMargin: 100
}
例如
InputPanel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
width: 30
}
那么 keyboardDesignHeight/Width
是怎么回事?好吧,这似乎是键盘的尺寸,当不需要缩放它时:
scaleHint : real
The keyboard style scale hint. This value is determined by dividingkeyboardHeight
bykeyboardDesignHeight
. All pixel dimensions must be proportional to this value.
This property is readonly!
所以设置这些不会禁用输入面板根据宽度自动调整大小。
您可能会使用它们来计算比率,并据此设置宽度以达到您想要的高度。
也许这个例子可以帮助你理解这个属性:
import QtQuick 2.6
import QtQuick.Window 2.0
import QtQuick.Controls 2.0
import QtQuick.VirtualKeyboard 2.0
ApplicationWindow {
id:appwindow
visible: true
width: 800
height: 600
title: qsTr("Test")
InputPanel {
id: ip
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
width: 800
Component.onCompleted: console.log(Object.keys(ip.keyboard.style).sort())
}
Slider {
id: sl
from: 0
to: 3000
}
Binding {
target: ip.keyboard.style
property: 'keyboardDesignHeight'
value: sl.value
}
}