问题描述
我的问题是,在我的 QML 应用程序中,我有一个菜单栏按钮,我想在左侧显示图标,在右侧显示文本,以便在我收缩菜单时隐藏文本并且只显示图标,但是当我将图标添加到按钮时,它在 Qt Quick Designer 中可见,但当我运行应用程序时,该图标根本不可见。
这是我的主要 QML 的代码:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
id: window
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Rectangle {
id: main_frame
color: "#282c34"
anchors.fill: parent
Rectangle {
id: menu_frame
width: 56
color: "#21252b"
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.leftMargin: 0
anchors.bottomMargin: 0
anchors.topMargin: 0
Button {
id: menu_button
text: "Hide"
icon.name: "menu_icon"
icon.source: "icons/menu.png"
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
leftPadding: 17
checkable: false
autoExclusive: false
checked: false
font.family: "Times New Roman"
display: AbstractButton.TextBesideIcon
highlighted: false
autoRepeat: false
flat: false
anchors.leftMargin: 0
anchors.rightMargin: 0
anchors.topMargin: 0
}
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)