ACF $AcfVersion:0$
TDesignerGuiCompBase.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/qmetaobject.h>
7
8
9// ACF includes
11
12
13namespace iqtgui
14{
15
20{
21public:
22 void setupUi(QWidget*){}
23 void retranslateUi(QWidget*){}
24};
25
26
30template <class UI, class WidgetType = QWidget>
31class TDesignerGuiCompBase: public TGuiComponentBase<WidgetType>, public UI
32{
33public:
35
36 // reimplemented (iqtgui::CGuiComponentBase)
37 virtual QWidget* CreateQtWidget(QWidget* parentPtr) override;
38
39protected:
40 // reimplemented (iqtgui::CGuiComponentBase)
41 virtual void OnGuiRetranslate() override;
42};
43
44
45// public methods
46
47// reimplemented (iqtgui::CGuiComponentBase)
48
49template <class UI, class WidgetType>
51{
52 Q_ASSERT(!BaseClass::IsGuiCreated());
53
54 QWidget* widgetPtr = BaseClass::CreateQtWidget(parentPtr);
55
56 WidgetType* concreteWidgetPtr = dynamic_cast<WidgetType*>(widgetPtr);
57 Q_ASSERT(concreteWidgetPtr != NULL);
58
59 UI::setupUi(concreteWidgetPtr);
60
61 return concreteWidgetPtr;
62}
63
64
65// protected methods
66
67// reimplemented (iqtgui::CGuiComponentBase)
68
69template <class UI, class WidgetType>
71{
72 Q_ASSERT(BaseClass::IsGuiCreated());
73
74 WidgetType* widgetPtr = dynamic_cast<WidgetType*>(BaseClass::GetWidget());
75 if (widgetPtr != NULL){
76 UI::retranslateUi(widgetPtr);
77 }
78
79 BaseClass::OnGuiRetranslate();
80}
81
82
83} // namespace iqtgui
84
85
86
87
Base class for all Qt GUI components, which use the Qt designer's UI.
TGuiComponentBase< WidgetType > BaseClass
virtual QWidget * CreateQtWidget(QWidget *parentPtr) override
Create slave widget object.
virtual void OnGuiRetranslate() override
Called from widget event filter when GUI should be retranslated.
Base class for all Qt GUI componentes.
UI setup-class to use with TDesignerGuiCompBase in case no real GUI setup is required.
void setupUi(QWidget *)
void retranslateUi(QWidget *)
#define NULL
Definition istd.h:74
Standard GUI specific interfaces and components based on Qt.