##// END OF EJS Templates
Fix layout issues with combobxes in chartsviewer
Michal Klocek -
r1754:707af58a67ca
parent child
Show More
@@ -95,13 +95,6 Window::Window(QWidget* parent) :
95 baseLayout->addItem(settingsLayout, 0, 3, 2, 1);
95 baseLayout->addItem(settingsLayout, 0, 3, 2, 1);
96 //create charts
96 //create charts
97
97
98 int i = m_widgetHash.count();
99 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
100 widget->setZValue(i--);
101 widget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
102 }
103
104
105 Charts::ChartList list = Charts::chartList();
98 Charts::ChartList list = Charts::chartList();
106
99
107 for(int i = 0 ; i < 6 ; ++i)
100 for(int i = 0 ; i < 6 ; ++i)
@@ -133,13 +126,13 Window::~Window()
133
126
134 void Window::connectSignals()
127 void Window::connectSignals()
135 {
128 {
136 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
129 QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
137 connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
130 QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
138 connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
131 QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
139 connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
132 QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
140 connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
133 QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
141 connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
134 QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
142 connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
135 QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
143 }
136 }
144
137
145 DataTable Window::generateRandomData(int listCount, int valueMax, int valueCount) const
138 DataTable Window::generateRandomData(int listCount, int valueMax, int valueCount) const
@@ -188,10 +181,10 void Window::createProxyWidgets()
188 m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox);
181 m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox);
189 }
182 }
190
183
191 QComboBox* Window::createThemeBox() const
184 QComboBox* Window::createThemeBox()
192 {
185 {
193 // settings layoutQGLWidget’
186 // settings layoutQGLWidget’
194 QComboBox* themeComboBox = new QComboBox();
187 QComboBox* themeComboBox = new ComboBox(this);
195 themeComboBox->addItem("Light", QChart::ChartThemeLight);
188 themeComboBox->addItem("Light", QChart::ChartThemeLight);
196 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
189 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
197 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
190 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
@@ -202,10 +195,10 QComboBox* Window::createThemeBox() const
202 return themeComboBox;
195 return themeComboBox;
203 }
196 }
204
197
205 QComboBox* Window::createAnimationBox() const
198 QComboBox* Window::createAnimationBox()
206 {
199 {
207 // settings layout
200 // settings layout
208 QComboBox* animationComboBox = new QComboBox();
201 QComboBox* animationComboBox = new ComboBox(this);
209 animationComboBox->addItem("No Animations", QChart::NoAnimation);
202 animationComboBox->addItem("No Animations", QChart::NoAnimation);
210 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
203 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
211 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
204 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
@@ -213,9 +206,9 QComboBox* Window::createAnimationBox() const
213 return animationComboBox;
206 return animationComboBox;
214 }
207 }
215
208
216 QComboBox* Window::createLegendBox() const
209 QComboBox* Window::createLegendBox()
217 {
210 {
218 QComboBox* legendComboBox = new QComboBox();
211 QComboBox* legendComboBox = new ComboBox(this);
219 legendComboBox->addItem("No Legend ", 0);
212 legendComboBox->addItem("No Legend ", 0);
220 legendComboBox->addItem("Legend Top", Qt::AlignTop);
213 legendComboBox->addItem("Legend Top", Qt::AlignTop);
221 legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
214 legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
@@ -428,3 +421,13 void Window::mouseReleaseEvent(QMouseEvent *event)
428 }
421 }
429 }
422 }
430 }
423 }
424
425 void Window::comboBoxFocused(QComboBox *combobox)
426 {
427 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
428 if(widget->widget()==combobox)
429 widget->setZValue(2.0);
430 else
431 widget->setZValue(0.0);
432 }
433 }
@@ -23,8 +23,8
23 #include <QMainWindow>
23 #include <QMainWindow>
24 #include <QChartGlobal>
24 #include <QChartGlobal>
25 #include <QHash>
25 #include <QHash>
26 #include <QComboBox>
26
27
27 class QComboBox;
28 class QCheckBox;
28 class QCheckBox;
29 class QGraphicsRectItem;
29 class QGraphicsRectItem;
30 class QGraphicsScene;
30 class QGraphicsScene;
@@ -41,6 +41,7 typedef QList<DataList> DataTable;
41
41
42 QTCOMMERCIALCHART_USE_NAMESPACE
42 QTCOMMERCIALCHART_USE_NAMESPACE
43
43
44
44 class Window: public QMainWindow
45 class Window: public QMainWindow
45 {
46 {
46 Q_OBJECT
47 Q_OBJECT
@@ -54,11 +55,12 private Q_SLOTS:
54
55
55 private:
56 private:
56 DataTable generateRandomData(int listCount,int valueMax,int valueCount) const;
57 DataTable generateRandomData(int listCount,int valueMax,int valueCount) const;
57 QComboBox* createThemeBox() const;
58 QComboBox* createThemeBox();
58 QComboBox* createAnimationBox() const;
59 QComboBox* createAnimationBox();
59 QComboBox* createLegendBox() const;
60 QComboBox* createLegendBox();
60 void connectSignals();
61 void connectSignals();
61 void createProxyWidgets();
62 void createProxyWidgets();
63 void comboBoxFocused(QComboBox *combox);
62
64
63 protected:
65 protected:
64 void mousePressEvent(QMouseEvent *event);
66 void mousePressEvent(QMouseEvent *event);
@@ -91,6 +93,24 private:
91 bool m_isZooming;
93 bool m_isZooming;
92 bool m_scroll;
94 bool m_scroll;
93 bool m_zoom;
95 bool m_zoom;
96
97 friend class ComboBox;
98 };
99
100 class ComboBox: public QComboBox
101 {
102 public:
103 ComboBox(Window* window,QWidget *parent = 0):QComboBox(parent),m_window(window)
104 {}
105
106 protected:
107 void focusInEvent(QFocusEvent *e)
108 {
109 QComboBox::focusInEvent(e);
110 m_window->comboBoxFocused(this);
111 }
112 private:
113 Window* m_window;
94 };
114 };
95
115
96 #endif
116 #endif
General Comments 0
You need to be logged in to leave comments. Login now