本页内容

ToolButton QML Type

一款外观适合ToolBar 的按钮。更多内容...

Import Statement: import QtQuick.Controls
Inherits:

Button

详细说明

ToolButton在功能上与Button 类似,但其外观更适合用于ToolBar 中。

包含工具按钮的工具栏

ToolBar {
    RowLayout {
        anchors.fill: parent
        ToolButton {
            text: qsTr("‹")
            onClicked: stack.pop()
        }
        Label {
            text: "Title"
            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
            Layout.fillWidth: true
        }
        ToolButton {
            text: qsTr("⋮")
            onClicked: menu.open()
        }
    }
}

ToolButton 继承了AbstractButton 的 API。例如,您可以使用AbstractButton API 设置text 、显示图标,并响应clicks 。

另请参阅 ToolBar 、自定义 ToolButton 以及Button 控件。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.