#include "controller.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); Controller *control = new Controller; control->view->show(); return a.exec(); } //------------------------------------------------------------------ //------------------------------------------------------------------ #ifndef CONTROLLER_H #define CONTROLLER_H #include #include #include #include #include class GraphicsView : public QGraphicsView { public: GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene) {} protected: virtual void resizeEvent(QResizeEvent *event) {} }; //------------------------------------------------------------------ //------------------------------------------------------------------ class Controller : public QWidget { Q_OBJECT public: explicit Controller(QWidget *parent = 0); GraphicsView *view; public slots: void setDesign(int); private: QGraphicsScene *scene; QThread *thread; int design; QLinearGradient *gradient; QBrush *brushBlue; QLinearGradient *gradientRed; QBrush *brushRed; }; #endif // CONTROLLER_H //------------------------------------------------------------------ //------------------------------------------------------------------ #include "controller.h" Controller::Controller(QWidget *parent) : QWidget(parent), design(0) { scene = new QGraphicsScene(-400, -300, 800, 600); view = new GraphicsView(scene); view->setRenderHint(QPainter::Antialiasing); view->setBackgroundBrush(QBrush(Qt::black)); view->setFrameStyle(QFrame::NoFrame); view->showFullScreen(); gradient = new QLinearGradient(0,scene->sceneRect().top(), 0, scene->sceneRect().bottom()); gradient->setColorAt(0, QColor(Qt::darkBlue)); gradient->setColorAt(0.3, QColor(Qt::black)); gradient->setColorAt(0.7, QColor(Qt::black)); gradient->setColorAt(1, QColor(Qt::darkBlue)); brushBlue = new QBrush(*gradient); gradientRed = new QLinearGradient(0,scene->sceneRect().top(), 0, scene->sceneRect().bottom()); gradientRed->setColorAt(0, QColor(Qt::darkRed)); gradientRed->setColorAt(0.3, QColor(Qt::black)); gradientRed->setColorAt(0.7, QColor(Qt::black)); gradientRed->setColorAt(1, QColor(Qt::darkRed)); brushRed = new QBrush(*gradientRed); view->setBackgroundBrush(*brushBlue); }