Resize health graphic when form is resized
authorunc0rr
Sat, 10 Jan 2009 15:48:02 +0000
changeset 1636 e528696f2177
parent 1635 cc5976f292f9
child 1637 897b37fc4966
Resize health graphic when form is resized
QTfrontend/statsPage.cpp
QTfrontend/statsPage.h
--- a/QTfrontend/statsPage.cpp	Sat Jan 10 15:45:15 2009 +0000
+++ b/QTfrontend/statsPage.cpp	Sat Jan 10 15:48:02 2009 +0000
@@ -19,10 +19,19 @@
 #include <QLabel>
 #include <QGridLayout>
 #include <QGraphicsScene>
-#include <QGraphicsView>
 
 #include "statsPage.h"
 
+FitGraphicsView::FitGraphicsView(QWidget* parent) : QGraphicsView(parent)
+{
+
+}
+
+void FitGraphicsView::resizeEvent(QResizeEvent * event)
+{
+	fitInView(sceneRect());
+}
+
 PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent)
 {
 	QFont * font14 = new QFont("MS Shell Dlg", 14);
@@ -37,7 +46,7 @@
 	labelGameStats->setTextFormat(Qt::RichText);
 	pageLayout->addWidget(labelGameStats, 0, 0, 1, 3);
 
-	graphic = new QGraphicsView(this);
+	graphic = new FitGraphicsView(this);
 	graphic->scale(1.0, -1.0);
 	pageLayout->addWidget(graphic, 1, 0, 1, 3);
 }
@@ -76,7 +85,6 @@
 	}
 
 	graphic->setScene(scene);
-	graphic->fitInView(graphic->sceneRect());
 }
 
 void PageGameStats::GameStats(char type, const QString & info)
--- a/QTfrontend/statsPage.h	Sat Jan 10 15:45:15 2009 +0000
+++ b/QTfrontend/statsPage.h	Sat Jan 10 15:48:02 2009 +0000
@@ -21,9 +21,19 @@
 
 #include <QVector>
 #include <QMap>
+#include <QGraphicsView>
 #include "pages.h"
 
-class QGraphicsView;
+class FitGraphicsView : public QGraphicsView
+{
+	Q_OBJECT
+
+public:
+	FitGraphicsView(QWidget* parent = 0);
+
+protected:
+	void resizeEvent(QResizeEvent * event);
+};
 
 class PageGameStats : public AbstractPage
 {
@@ -34,7 +44,7 @@
 
 	QPushButton *BtnBack;
 	QLabel *labelGameStats;
-	QGraphicsView * graphic;
+	FitGraphicsView * graphic;
 
 public slots:
 	void GameStats(char type, const QString & info);