Qt Utilities  5.6.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Public Member Functions | Protected Member Functions | List of all members
Widgets::ButtonOverlay Class Reference

The ButtonOverlay class is used to display buttons on top of other widgets. More...

#include <buttonoverlay.h>

Inheritance diagram for Widgets::ButtonOverlay:
[legend]

Public Member Functions

 ButtonOverlay (QWidget *widget)
 Constructs a button overlay for the specified widget. More...
 
virtual ~ButtonOverlay ()
 Destroys the button overlay. More...
 
QHBoxLayout * buttonLayout ()
 Returns the layout manager holding the buttons. More...
 
bool isClearButtonEnabled () const
 Returns whether the clear button is enabled. More...
 
void setClearButtonEnabled (bool enabled)
 Sets whether the clear button is enabled. More...
 
bool isInfoButtonEnabled () const
 Returns whether the info button is enabled. More...
 
void enableInfoButton (const QPixmap &pixmap, const QString &infoText)
 Shows an info button with the specified pixmap and infoText. More...
 
void disableInfoButton ()
 Hides an info button if one is shown. More...
 
void addCustomButton (QWidget *button)
 Adds a custom button. More...
 
void insertCustomButton (int index, QWidget *button)
 Inserts a custom button at the specified index. More...
 
void removeCustomButton (QWidget *button)
 Removes the specified custom button. More...
 
virtual bool isCleared () const
 Returns whether the related widget is cleared. More...
 

Protected Member Functions

void updateClearButtonVisibility (bool visible)
 Updates the visibility of the clear button. More...
 
virtual void handleClearButtonClicked ()
 Clears the related widget. More...
 

Detailed Description

The ButtonOverlay class is used to display buttons on top of other widgets.

The class creates a new layout manager and sets it to the widget which is specified when constructing an instance. Thus this widget must not already have a layout manager.

The class is used to implement widget customization like ClearLineEidt and ClearComboBox.

Definition at line 17 of file buttonoverlay.h.

Constructor & Destructor Documentation

◆ ButtonOverlay()

Widgets::ButtonOverlay::ButtonOverlay ( QWidget *  widget)
explicit

Constructs a button overlay for the specified widget.

Parameters
widgetSpecifies the widget to display the buttons on.

Definition at line 34 of file buttonoverlay.cpp.

◆ ~ButtonOverlay()

Widgets::ButtonOverlay::~ButtonOverlay ( )
virtual

Destroys the button overlay.

Definition at line 55 of file buttonoverlay.cpp.

Member Function Documentation

◆ addCustomButton()

void Widgets::ButtonOverlay::addCustomButton ( QWidget *  button)

Adds a custom button.

The button overlay takes ownership over the specified button.

Definition at line 121 of file buttonoverlay.cpp.

◆ buttonLayout()

QHBoxLayout * Widgets::ButtonOverlay::buttonLayout ( )
inline

Returns the layout manager holding the buttons.

Definition at line 51 of file buttonoverlay.h.

◆ disableInfoButton()

void Widgets::ButtonOverlay::disableInfoButton ( )

Hides an info button if one is shown.

See also
ButtonOverlay::enableInfoButton()

Definition at line 107 of file buttonoverlay.cpp.

◆ enableInfoButton()

void Widgets::ButtonOverlay::enableInfoButton ( const QPixmap &  pixmap,
const QString &  infoText 
)

Shows an info button with the specified pixmap and infoText.

If there is already an info button enabled, it gets replaced with the new button.

See also
ButtonOverlay::disableInfoButton()

Definition at line 87 of file buttonoverlay.cpp.

◆ handleClearButtonClicked()

void Widgets::ButtonOverlay::handleClearButtonClicked ( )
protectedvirtual

Clears the related widget.

This method is meant to be implemented when subclassing.

Definition at line 163 of file buttonoverlay.cpp.

◆ insertCustomButton()

void Widgets::ButtonOverlay::insertCustomButton ( int  index,
QWidget *  button 
)

Inserts a custom button at the specified index.

The button overlay takes ownership over the specified button.

Definition at line 131 of file buttonoverlay.cpp.

◆ isClearButtonEnabled()

bool Widgets::ButtonOverlay::isClearButtonEnabled ( ) const
inline

Returns whether the clear button is enabled.

Definition at line 59 of file buttonoverlay.h.

◆ isCleared()

bool Widgets::ButtonOverlay::isCleared ( ) const
virtual

Returns whether the related widget is cleared.

This method is meant to be implemented when subclassing.

Reimplemented in Widgets::ClearSpinBox, Widgets::ClearLineEdit, Widgets::ClearComboBox, and Widgets::ClearPlainTextEdit.

Definition at line 171 of file buttonoverlay.cpp.

◆ isInfoButtonEnabled()

bool Widgets::ButtonOverlay::isInfoButtonEnabled ( ) const
inline

Returns whether the info button is enabled.

Definition at line 67 of file buttonoverlay.h.

◆ removeCustomButton()

void Widgets::ButtonOverlay::removeCustomButton ( QWidget *  button)

Removes the specified custom button.

The ownership of widget remains the same as when it was added.

Definition at line 141 of file buttonoverlay.cpp.

◆ setClearButtonEnabled()

void Widgets::ButtonOverlay::setClearButtonEnabled ( bool  enabled)

Sets whether the clear button is enabled.

Definition at line 61 of file buttonoverlay.cpp.

◆ updateClearButtonVisibility()

void Widgets::ButtonOverlay::updateClearButtonVisibility ( bool  visible)
protected

Updates the visibility of the clear button.

This method is meant to be called when subclassing.

Definition at line 151 of file buttonoverlay.cpp.


The documentation for this class was generated from the following files: