Manages a collection of QWidget instances displayed within a QStackedWidget.
More...
#include <HomeCardManager.h>
|
QStackedWidget * | stacked_widget |
| A pointer to the QStackedWidget managed by this class.
|
|
std::shared_ptr< QMutex > | mutex |
| A shared pointer to a QMutex for thread-safe access.
|
|
Manages a collection of QWidget instances displayed within a QStackedWidget.
This class provides an interface for adding, removing, and querying the number of "cards" (widgets) managed by a QStackedWidget. It ensures thread-safe operations on the managed widgets through the use of a QMutex.
- Note
- This class is non-copyable and non-movable to ensure a single, controlled instance managing the QStackedWidget.
◆ HomeCardManager()
HomeCardManager::HomeCardManager |
( |
QStackedWidget * |
widget | ) |
|
|
explicit |
Constructs a HomeCardManager instance.
- Parameters
-
widget | A pointer to the QStackedWidget that this manager will control. The manager does not take ownership of the QStackedWidget. |
◆ accessible_card_cnt()
int HomeCardManager::accessible_card_cnt |
( |
| ) |
const |
|
virtual |
Returns the number of accessible cards (widgets) currently managed.
- This method provides a count of the widgets that are currently part of the QStackedWidget managed by this class. It ensures thread-safe access to this count.
- Returns
- The integer count of accessible widgets.
◆ installWidget()
void HomeCardManager::installWidget |
( |
QWidget * |
widget | ) |
|
|
virtual |
Installs a new widget into the managed QStackedWidget.
- This method adds the provided widget to the QStackedWidget, making it available for display. It handles thread-safe access to the stacked widget.
- Parameters
-
widget | A pointer to the QWidget to be installed. The manager takes ownership of the widget if the QStackedWidget takes ownership. |
◆ Q_DISABLE_COPY_MOVE()
Disables copy construction and copy assignment for HomeCardManager.
- This macro ensures that instances of HomeCardManager cannot be copied, enforcing a single point of control over the managed QStackedWidget.
◆ removeWidget()
void HomeCardManager::removeWidget |
( |
QWidget * |
widget | ) |
|
|
virtual |
Removes a widget from the managed QStackedWidget.
- This method removes the specified widget from the QStackedWidget. It handles thread-safe access. The caller is responsible for deleting the widget if the QStackedWidget does not manage its lifetime.
- Parameters
-
widget | A pointer to the QWidget to be removed. |
◆ mutex
std::shared_ptr<QMutex> HomeCardManager::mutex |
|
protected |
A shared pointer to a QMutex for thread-safe access.
- This mutex is used to protect concurrent access to the
stacked_widget
and its operations, ensuring data integrity in multithreaded environments.
◆ stacked_widget
QStackedWidget* HomeCardManager::stacked_widget |
|
protected |
A pointer to the QStackedWidget managed by this class.
- This member holds the reference to the QStackedWidget where the "cards" (individual widgets) are displayed.
The documentation for this class was generated from the following files:
- builtin/page/home_card_manager/HomeCardManager.h
- builtin/page/home_card_manager/HomeCardManager.cpp