NDEVR
API Documentation
WidgetInit

Provides a way to lazily initialize widgets when needed but still pass them to container dialogs. More...

Public Member Functions

 WidgetInit (QWidget *widget)
 Constructs a WidgetInit with an already-created widget.
 WidgetInit (std::function< QWidget *()> init)
 Constructs a WidgetInit with a lazy-initialization function.
virtual QWidget * getWidget ()
 Returns the widget, creating it lazily if it has not been initialized yet.

Protected Attributes

const std::function< QWidget *()> m_create_widget
 The factory function for lazy widget creation.
QWidget * m_widget = nullptr
 The cached widget pointer.

Detailed Description

Provides a way to lazily initialize widgets when needed but still pass them to container dialogs.


Useful for adding things to Settings dialogs or other large structures where they may never be initialized.

Definition at line 12 of file WidgetInit.h.

Constructor & Destructor Documentation

◆ WidgetInit() [1/2]

WidgetInit::WidgetInit ( std::function< QWidget *()> init)
inline

Constructs a WidgetInit with a lazy-initialization function.

Parameters
[in]initThe function that creates the widget on first access.

Definition at line 17 of file WidgetInit.h.

References m_create_widget.

◆ WidgetInit() [2/2]

WidgetInit::WidgetInit ( QWidget * widget)
inline

Constructs a WidgetInit with an already-created widget.

Parameters
[in]widgetThe pre-existing widget.

Definition at line 22 of file WidgetInit.h.

References m_widget.

Member Function Documentation

◆ getWidget()

virtual QWidget * WidgetInit::getWidget ( )
inlinevirtual

Returns the widget, creating it lazily if it has not been initialized yet.

Returns
The managed QWidget pointer.

Definition at line 27 of file WidgetInit.h.

References m_create_widget, and m_widget.


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