src/radioGroup.h

changeset 794
c254ddc6618b
parent 655
b376645315ab
child 844
11587d419d2f
equal deleted inserted replaced
793:ceb1b1aaf7db 794:c254ddc6618b
27 class QCheckBox; 27 class QCheckBox;
28 class QButtonGroup; 28 class QButtonGroup;
29 class QBoxLayout; 29 class QBoxLayout;
30 class QRadioButton; 30 class QRadioButton;
31 31
32 // =============================================================================
33 // RadioGroup
34 // 32 //
35 // Convenience widget - is a groupbox of radio buttons. 33 // Convenience widget - is a groupbox of radio buttons.
36 // ============================================================================= 34 //
37 class RadioGroup : public QGroupBox 35 class RadioGroup : public QGroupBox
38 { 36 {
39 Q_OBJECT 37 Q_OBJECT
40 38
41 public: 39 public:
42 typedef QList<QRadioButton*>::Iterator Iterator; 40 typedef QList<QRadioButton*>::Iterator Iterator;
43 41
44 explicit RadioGroup() 42 explicit RadioGroup()
45 { 43 {
46 init (Qt::Vertical); 44 init (Qt::Vertical);
47 } 45 }
48 46
49 explicit RadioGroup (QWidget* parent = null) : QGroupBox (parent) 47 explicit RadioGroup (QWidget* parent = null) : QGroupBox (parent)
50 { 48 {
51 init (Qt::Vertical); 49 init (Qt::Vertical);
52 } 50 }
53 51
54 explicit RadioGroup (const QString& title, QWidget* parent = null); 52 explicit RadioGroup (const QString& title, QWidget* parent = null);
55 explicit RadioGroup (const QString& title, QList<char const*> entries, int const defaultId, 53 explicit RadioGroup (const QString& title, QList<char const*> entries, int const defaultId,
56 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = null); 54 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = null);
57 55
58 void addButton (const char* entry); 56 void addButton (const char* entry);
59 void addButton (QRadioButton* button); 57 void addButton (QRadioButton* button);
60 Iterator begin(); 58 Iterator begin();
61 Iterator end(); 59 Iterator end();
62 void init (Qt::Orientation orient); 60 void init (Qt::Orientation orient);
63 bool isChecked (int n) const; 61 bool isChecked (int n) const;
64 void rowBreak(); 62 void rowBreak();
65 void setCurrentRow (int row); 63 void setCurrentRow (int row);
66 void setValue (int val); 64 void setValue (int val);
67 int value() const; 65 int value() const;
68 66
69 QRadioButton* operator[] (int n) const; 67 QRadioButton* operator[] (int n) const;
70 RadioGroup& operator<< (QRadioButton* button); 68 RadioGroup& operator<< (QRadioButton* button);
71 RadioGroup& operator<< (const char* entry); 69 RadioGroup& operator<< (const char* entry);
72 70
73 signals: 71 signals:
74 void buttonPressed (int btn); 72 void buttonPressed (int btn);
75 void buttonReleased (int btn); 73 void buttonReleased (int btn);
76 void valueChanged (int val); 74 void valueChanged (int val);
77 75
78 private: 76 private:
79 QList<QRadioButton*> m_objects; 77 QList<QRadioButton*> m_objects;
80 QList<QBoxLayout*> m_layouts; 78 QList<QBoxLayout*> m_layouts;
81 QBoxLayout* m_coreLayout; 79 QBoxLayout* m_coreLayout;
82 QBoxLayout* m_currentLayout; 80 QBoxLayout* m_currentLayout;
83 bool m_vert; 81 bool m_vert;
84 int m_curId, m_defId, m_oldId; 82 int m_curId, m_defId, m_oldId;
85 QButtonGroup* m_buttonGroup; 83 QButtonGroup* m_buttonGroup;
86 84
87 Q_DISABLE_COPY (RadioGroup) 85 Q_DISABLE_COPY (RadioGroup)
88 86
89 private slots: 87 private slots:
90 void slot_buttonPressed (int btn); 88 void slot_buttonPressed (int btn);
91 void slot_buttonReleased (int btn); 89 void slot_buttonReleased (int btn);
92 }; 90 };

mercurial