NDEVR
API Documentation
WidgetInit.h
1#pragma once
2class QWidget;
3namespace NDEVR
4{
5 class DockItem;
13 {
14 public:
17 WidgetInit(std::function<QWidget*()> init)
18 : m_create_widget(init)
19 {}
20
22 WidgetInit(QWidget* widget)
23 : m_widget(widget)
24 {}
25
27 virtual QWidget* getWidget()
28 {
29 if (m_widget == nullptr)
31 return m_widget;
32 }
33 protected:
34 const std::function<QWidget*()> m_create_widget;
35 QWidget* m_widget = nullptr;
36 };
37
43 {
44 public:
47 DockInit(std::function<QCustomDockWidget*()> init)
48 : m_create_dock(init)
49 {}
50
53 : m_dock_item(init)
54 {}
55
57 bool isInit() const
58 {
59 return m_dock_item != nullptr;
60 }
61
64 {
65 if (m_dock_item == nullptr)
67 return m_dock_item;
68 }
69 protected:
70 const std::function<QCustomDockWidget*()> m_create_dock;
72 };
73}
bool isInit() const
Returns whether the dock widget has been initialized.
Definition WidgetInit.h:57
DockInit(std::function< QCustomDockWidget *()> init)
Constructs a DockInit with a lazy-initialization function.
Definition WidgetInit.h:47
QCustomDockWidget * m_dock_item
The cached dock widget pointer.
Definition WidgetInit.h:71
DockInit(QCustomDockWidget *init)
Constructs a DockInit with an already-created dock widget.
Definition WidgetInit.h:52
const std::function< QCustomDockWidget *()> m_create_dock
The factory function for lazy dock creation.
Definition WidgetInit.h:70
virtual QCustomDockWidget * getDock()
Returns the dock widget, creating it lazily if it has not been initialized yet.
Definition WidgetInit.h:63
The root class that allows interface with the NDEVR API Widget Docking system.
Definition DockItem.h:56
Provides a wrapper for a widget that can be docked inside a Container or floated as a top-level windo...
WidgetInit(std::function< QWidget *()> init)
Constructs a WidgetInit with a lazy-initialization function.
Definition WidgetInit.h:17
WidgetInit(QWidget *widget)
Constructs a WidgetInit with an already-created widget.
Definition WidgetInit.h:22
virtual QWidget * getWidget()
Returns the widget, creating it lazily if it has not been initialized yet.
Definition WidgetInit.h:27
const std::function< QWidget *()> m_create_widget
The factory function for lazy widget creation.
Definition WidgetInit.h:34
QWidget * m_widget
The cached widget pointer.
Definition WidgetInit.h:35
The primary namespace for the NDEVR SDK.