17 */ |
17 */ |
18 |
18 |
19 #ifndef LABELEDWIDGET_H |
19 #ifndef LABELEDWIDGET_H |
20 #define LABELEDWIDGET_H |
20 #define LABELEDWIDGET_H |
21 |
21 |
|
22 #include "common.h" |
22 #include <QLabel> |
23 #include <QLabel> |
23 #include <QBoxLayout> |
24 #include <QBoxLayout> |
24 |
25 |
25 // ============================================================================= |
26 // ============================================================================= |
26 // LabeledWidget |
27 // LabeledWidget |
27 // |
28 // |
28 // Convenience class for a widget with a label beside it. |
29 // Convenience class for a widget with a label beside it. |
29 // ============================================================================= |
30 // ============================================================================= |
30 template<class R> class LabeledWidget : public QWidget { |
31 template<class R> class LabeledWidget : public QWidget { |
|
32 PROPERTY (QLabel*, label, setLabel) |
|
33 PROPERTY (R*, widget, setWidget) |
|
34 |
31 public: |
35 public: |
32 explicit LabeledWidget (const char* labelstr, QWidget* parent = null) : QWidget (parent) { |
36 explicit LabeledWidget (const char* labelstr, QWidget* parent = null) : QWidget (parent) { |
33 m_widget = new R (this); |
37 m_widget = new R (this); |
34 commonInit (labelstr); |
38 commonInit (labelstr); |
35 } |
39 } |
43 explicit LabeledWidget (QWidget* parent = 0, Qt::WindowFlags f = 0) { |
47 explicit LabeledWidget (QWidget* parent = 0, Qt::WindowFlags f = 0) { |
44 m_widget = new R (this); |
48 m_widget = new R (this); |
45 commonInit (""); |
49 commonInit (""); |
46 } |
50 } |
47 |
51 |
48 R* widget () const { return m_widget; } |
|
49 R* w () const { return m_widget; } |
52 R* w () const { return m_widget; } |
50 QLabel* label () const { return m_label; } |
|
51 QLabel* l () const { return m_label; } |
|
52 void setWidget (R* widget) { m_widget = widget; } |
|
53 void setLabel (QLabel* label) { m_label = label; } |
|
54 operator R* () { return m_widget; } |
53 operator R* () { return m_widget; } |
55 |
54 |
56 private: |
55 private: |
57 Q_DISABLE_COPY (LabeledWidget<R>) |
56 Q_DISABLE_COPY (LabeledWidget<R>) |
58 |
57 |