Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicktoolbutton.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
8
9#include <QtGui/qpa/qplatformtheme.h>
10
12
13/*!
14 \qmltype ToolButton
15 \inherits Button
16//! \nativetype QQuickToolButton
17 \inqmlmodule QtQuick.Controls
18 \since 5.7
19 \ingroup qtquickcontrols-buttons
20 \brief Button with a look suitable for a ToolBar.
21
22 ToolButton is functionally similar to \l Button, but provides a look that
23 is more suitable within a \l ToolBar.
24
25 \image qtquickcontrols-toolbar.png
26 {Toolbar containing tool buttons}
27
28 \snippet qtquickcontrols-toolbar.qml 1
29
30 ToolButton inherits its API from AbstractButton. For instance, you can set
31 \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon},
32 and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API.
33
34 \sa ToolBar, {Customizing ToolButton}, {Button Controls}
35*/
36
37class Q_QUICKTEMPLATES2_EXPORT QQuickToolPrivate : public QQuickButtonPrivate
38{
39 Q_DECLARE_PUBLIC(QQuickToolButton)
40
41 QQuickToolPrivate() { setSizePolicy(QLayoutPolicy::Fixed, QLayoutPolicy::Fixed); }
42
43public:
44 QPalette defaultPalette() const override { return QQuickTheme::palette(QQuickTheme::ToolBar); }
45};
46
47QQuickToolButton::QQuickToolButton(QQuickItem *parent)
48 : QQuickButton(*(new QQuickToolPrivate), parent)
49{
50}
51
52QFont QQuickToolButton::defaultFont() const
53{
54 return QQuickTheme::font(QQuickTheme::ToolBar);
55}
56
57QT_END_NAMESPACE
58
59#include "moc_qquicktoolbutton_p.cpp"
Button with a look suitable for a ToolBar.
Combined button and popup list for selecting options.