TDesignerGuiCompBase.h
Go to the documentation of this file.
1 #ifndef iqtgui_TDesignerGuiCompBase_included
2 #define iqtgui_TDesignerGuiCompBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/qmetaobject.h>
7 
8 
9 // ACF includes
11 
12 
13 namespace iqtgui
14 {
15 
16 
20 template <class UI, class WidgetType = QWidget>
21 class TDesignerGuiCompBase: public TGuiComponentBase<WidgetType>, public UI
22 {
23 public:
25 
26  // reimplemented (iqtgui::CGuiComponentBase)
27  virtual QWidget* CreateQtWidget(QWidget* parentPtr);
28 
29 protected:
30  // reimplemented (iqtgui::CGuiComponentBase)
31  virtual void OnGuiRetranslate();
32 };
33 
34 
35 // public methods
36 
37 // reimplemented (iqtgui::CGuiComponentBase)
38 
39 template <class UI, class WidgetType>
41 {
42  Q_ASSERT(!BaseClass::IsGuiCreated());
43 
44  QWidget* widgetPtr = BaseClass::CreateQtWidget(parentPtr);
45 
46  WidgetType* concreteWidgetPtr = dynamic_cast<WidgetType*>(widgetPtr);
47  Q_ASSERT(concreteWidgetPtr != NULL);
48 
49  UI::setupUi(concreteWidgetPtr);
50 
51  return concreteWidgetPtr;
52 }
53 
54 
55 // protected methods
56 
57 // reimplemented (iqtgui::CGuiComponentBase)
58 
59 template <class UI, class WidgetType>
61 {
62  Q_ASSERT(BaseClass::IsGuiCreated());
63 
64  WidgetType* widgetPtr = dynamic_cast<WidgetType*>(BaseClass::GetWidget());
65  if (widgetPtr != NULL){
66  UI::retranslateUi(widgetPtr);
67  }
68 
69  BaseClass::OnGuiRetranslate();
70 }
71 
72 
73 } // namespace iqtgui
74 
75 
76 #endif // !iqtgui_TDesignerGuiCompBase_included
77 
78 
virtual void OnGuiRetranslate()
Called from widget event filter when GUI should be retranslated.
Base class for all Qt GUI components, which use the Qt designer's UI.
Base class for all Qt GUI componentes.
virtual QWidget * CreateQtWidget(QWidget *parentPtr)
Create slave widget object.
#define NULL
Definition: istd.h:64
TGuiComponentBase< WidgetType > BaseClass

© 2007-2017 Witold Gantzke and Kirill Lepskiy