我遇到过QFontMetrics? http://doc.qt.io/qt-5/qfontmetrics.html
这给出了当前字体的高度和宽度 .
我需要在我使用Scale类的不同显示器上以全屏模式运行我的应用程序 . http://doc.qt.io/qt-5/qml-qtquick-scale.html
返回当前屏幕的高度和宽度 .
有没有办法使用QFontMetrics或其他任何东西根据显示器大小更改字体大小?
ApplicationWindow
{
id: head
visible: true
width: Screen.width
height: Screen.height
title: "Novus Pilot"
property var id: 0;
Draw_on_qimage
{
id: draw_on_qimage
anchors.fill: parent
parent: image
scaleX: head.width / 640
scaleY: head.height / 480
}
}
Draw_on_qimage
是一个cpp类 .
1 回答
最简单的方法是将QFont设置为项目的Q_PROPERTY,以便您可以从QML设置它:
要设置其大小,我们使用QFont的pointSize属性:
其中some_function是 Build 字体大小和窗口大小之间关系的函数 .