我正在尝试为我的应用程序编写一个顶部栏,主要应该包含应用程序徽标(一个小图像)和应用程序标题(只是文本).此外,我希望这个顶栏可以根据窗口的高度自动调整大小.
我是QML的新手,但我想我应该将这些组件包装在一个Row或一个RowLayout组件中.这是我的示例代码:
import QtQuick 2.0
import QtQuick.Layouts 1.0
Rectangle
{
id: mainwindow
width: 1024
height: 600
Row
{
id: rowlayout
height: logoimage.height
spacing: 5
property int count: 3
anchors
{
left: parent.left
right: parent.right
top: parent.top
}
Image
{
id: logoimage
source: "qrc:/images/resources/images/icon.png"
height: mainwindow.height / 20
anchors.top: parent.top
anchors.left: parent.left
}
Text
{
id: logotext
text: qsTr("This is my logo text")
font.pixelSize: parent.height
font.family: "Sans Serif"
height: parent.height
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.left: logoimage.right
} …Run Code Online (Sandbox Code Playgroud)