CDPBaseButtonMenu Class
The Menu Button is a convenience button class that is configured to be used in left side menus. More...
Header: | #include <CDPBaseWidgets/CDPBaseButtonMenu.h> |
Inherits: | CDPBaseButtonPopDlg |
Properties
|
- 8 properties inherited from CDPBaseButtonPopDlg
- 21 properties inherited from CDPBaseButtonMarker
- 5 properties inherited from CDPBaseButtonMsg
- 31 properties inherited from CDPBaseButton
Public Functions
CDPBaseButtonMenu(QWidget *parent = 0) | |
virtual | ~CDPBaseButtonMenu() |
QString | icon() const |
QString | iconChecked() const |
int | iconDiameter() const |
int | margin() const |
void | setIcon(const QString &svg) |
void | setIconChecked(const QString &pixPath) |
void | setIconDiameter(int diameter) |
void | setMargin(int margin) |
void | setSpacing(int spacing) |
void | setText(const QString &text) |
bool | showText() const |
int | spacing() const |
QString | text() const |
Reimplemented Public Functions
virtual void | setIQtCDPPointer(IQtCDP *pIQtCDP) |
- 1 public function inherited from CDPBaseButtonPopDlg
- 3 public functions inherited from CDPBaseButtonMarker
- 11 public functions inherited from DialogLoader
- 3 public functions inherited from RoutingContainerBase
- 9 public functions inherited from CDPBaseButtonMsg
- 48 public functions inherited from MultiMarker
- 62 public functions inherited from CDPBaseButton
- 17 public functions inherited from CDPBaseCom
- 26 public functions inherited from CDPBasePadLauncher
- 3 public functions inherited from StateChanger
- 4 public functions inherited from CDPBaseControlVisible
Public Slots
void | setShowText(bool show) |
virtual void | setWidgetTheme(const QString &theme) override |
- 3 public slots inherited from CDPBaseButtonPopDlg
- 3 public slots inherited from CDPBaseButtonMarker
- 5 public slots inherited from CDPBaseButtonMsg
- 15 public slots inherited from CDPBaseButton
Protected Functions
QSize | minimumSizeHint() const |
QSize | sizeHint() const |
- 1 protected function inherited from CDPBaseButtonPopDlg
- 2 protected functions inherited from CDPBaseButtonMarker
- 1 protected function inherited from CDPBaseButtonMsg
- 13 protected functions inherited from CDPBaseButton
- 4 protected functions inherited from CDPBaseCom
- 1 protected function inherited from CDPBasePadLauncher
- 1 protected function inherited from CDPBaseControlVisible
Additional Inherited Members
- 1 signal inherited from CDPBaseButtonPopDlg
- 2 signals inherited from CDPBaseButtonMarker
- 3 signals inherited from CDPBaseButtonMsg
- 6 signals inherited from CDPBaseButton
- 2 static public members inherited from CDPBaseCom
- 9 protected slots inherited from CDPBaseButton
Detailed Description
The Menu Button is a convenience button class that is configured to be used in left side menus.
The user can provide an optional icon to show to the left of the button text, using the property named iconSvg. Use the property named iconDiameter to adjust the size of the icon.
The menu is usually created by adding and ordinary widget and a stacked widget in a horizontal layout. The widget is given a maximum width using the property named, maximumSize. Create an additonal widget to hold the buttons and place this in a horizontal layout with a vertical CDPBaseLine. Adjust the layout margins and spacing to 0 when wanting a tight design.
Connect the buttons to the stacked widget by first pressing F4 to enter connection mode. Now, click and drag from the first button to the stacked widget and release. In the dialog that pops up, select checked(int) among the button signals and select indexChanged(int) on the stacked widget. Press OK and repeat the process for each button. Go back to editing mode by hitting F3 and configure the valueToEmit property of each button with the index that the different buttons should trigger. Note that it's also possible to do the page switching using CDP communication instead of signals and slots. This will allow the user to switch page externally. For instance, using a joystick or similar.
The following example, How to use buttons in a menu, demonstrates how to create the menu using ordinary buttons. This is similar to using CDPBaseButtonMenu, but with less features and styling abilities.
There are two properties for specifying an icon in front of the text, icon and iconChecked. This is in case the user wants to use raster images like PNG and still be able to show two different images in checked and unchecked state. The iconChecked will not be used if adding a structured SVG to the icon property as explained in the following section.
Styling by SVG
Use the svgFile property to style the widget using a svg file. Styling by svg enables switching between different themes in runtime (as long as the files are placed at identical locations within theme directories).
The structure of the SVG is the same as for CDPBaseButton. The same goes for the optional icon that can be added in front of the button text.
Note: The button can be used with just the icon, just the text or both. Set iconDiameter to {0} to remove the icon and use showText for toggling text on/off.
Property Documentation
icon : QString
This property holds the path to the svg or raster file that styles the widget icon.
The icon can be an ordinary SVG, a raster file like PNG, or a svg file that complies with the CDPBaseButton style structure. When not adding a CDP structured SVG, the iconChecked property must be used if wanting to specify a different icon to show when the button is checked.
The path can be either to a resource or a file on disk. Note that resources can be overridden by files on disk with identical names.
Access functions:
QString | icon() const |
void | setIcon(const QString &svg) |
See also iconChecked.
iconChecked : QString
This property holds the path to the svg or raster file that styles the widget icon when the button is checked.
There is no need to configure this property if a CDP structured svg is provided in the icon property as it will anyway be overrided.
The path can be either to a resource or a file on disk. Note that resources can be overridden by files on disk with identical names.
Access functions:
QString | iconChecked() const |
void | setIconChecked(const QString &pixPath) |
See also icon.
iconDiameter : int
This property holds the diameter of the icon image in pixels.
Access functions:
int | iconDiameter() const |
void | setIconDiameter(int diameter) |
margin : int
This property holds the margins around the icon and label.
Access functions:
int | margin() const |
void | setMargin(int margin) |
showText : bool
This property holds whether to hide or show the button text.
Access functions:
bool | showText() const |
void | setShowText(bool show) |
spacing : int
This property holds the spacing between the icon and label.
Access functions:
int | spacing() const |
void | setSpacing(int spacing) |
svgFile : QString
Access functions:
QString | svgFile() const |
void | setSvgFile(const QString &svg) |
text : QString
This property holds the text to show on the widget.
Access functions:
QString | text() const |
void | setText(const QString &text) |
Member Function Documentation
CDPBaseButtonMenu::CDPBaseButtonMenu(QWidget *parent = 0)
Default constructs an instance of CDPBaseButtonMenu.
[virtual]
CDPBaseButtonMenu::~CDPBaseButtonMenu()
Destroys the instance of CDPBaseButtonMenu. The destructor is virtual.
[protected]
QSize CDPBaseButtonMenu::minimumSizeHint() const
[virtual]
void CDPBaseButtonMenu::setIQtCDPPointer(IQtCDP *pIQtCDP)
[override virtual slot]
void CDPBaseButtonMenu::setWidgetTheme(const QString &theme)
[protected]
QSize CDPBaseButtonMenu::sizeHint() const
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.