QGIS API Documentation 4.3.0-Master (3b7b3208a79)
Loading...
Searching...
No Matches
qgstoolbuttonaction.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstoolbuttonaction.h
3 ---------------------
4 begin : October 2026
5 copyright : (C) 2026 by Alexander Bruy
6 email : alexander dot bruy at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSTOOLBUTTONACTION_H
19#define QGSTOOLBUTTONACTION_H
20
21#include "qgis_gui.h"
22
23#include <QPointer>
24#include <QToolButton>
25#include <QWidgetAction>
26
27class QMenu;
28
40class GUI_EXPORT QgsToolButtonAction : public QWidgetAction
41{
42 Q_OBJECT
43 public:
48 explicit QgsToolButtonAction( QObject *parent = nullptr );
49
53 void setAutoRaise( bool autoRaise );
54
61 void setPopupMode( QToolButton::ToolButtonPopupMode mode );
62
66 void setToolButtonStyle( Qt::ToolButtonStyle style );
67
75 void setMenu( QMenu *menu );
76
84 void addActions( const QList<QAction *> &actions );
85
96 void setDefaultAction( QAction *action );
97
103 QAction *defaultAction() const;
104
105 protected:
106 QWidget *createWidget( QWidget *parent ) override;
107
108 private:
109 void applyState( QToolButton *button ) const;
110 void updateButtons();
111
112 private:
113 bool mAutoRaise = false;
114 Qt::ToolButtonStyle mToolButtonStyle = Qt::ToolButtonStyle::ToolButtonIconOnly;
115 QToolButton::ToolButtonPopupMode mPopupMode = QToolButton::ToolButtonPopupMode::DelayedPopup;
116 QPointer< QMenu > mMenu;
117 QList< QAction * > mButtonActions;
118 QPointer< QAction > mDefaultAction;
119};
120
121#endif // QGSTOOLBUTTONACTION_H
void addActions(const QList< QAction * > &actions)
Appends actions to the button's list of actions.
void setPopupMode(QToolButton::ToolButtonPopupMode mode)
Sets the popup mode to use for button's popup menu.
QAction * defaultAction() const
Returns the default action.
void setMenu(QMenu *menu)
Associates a menu with this tool button.
QgsToolButtonAction(QObject *parent=nullptr)
Constructor for QgsToolButtonAction.
void setToolButtonStyle(Qt::ToolButtonStyle style)
Sets the toolbutton style, e.g.
QWidget * createWidget(QWidget *parent) override
void setDefaultAction(QAction *action)
Sets the default action to action.
void setAutoRaise(bool autoRaise)
Sets whether auto-raise is enabled.