From 9893e03b7d4377bcfd51ef4a8b14c9da9bf71d36 Mon Sep 17 00:00:00 2001 From: wmj Date: Mon, 11 Dec 2017 17:08:20 +0800 Subject: [PATCH] first step --- DataStructureProject.pro | 8 ++++++-- cars.cpp | 9 +++++++++ cars.h | 24 ++++++++++++++++++++++ mainwindow.cpp | 22 +++++++++++++++++++- mainwindow.h | 4 ++++ mainwindow.ui | 43 +++++++++++++++++++++++++++++----------- monitor.cpp | 17 ++++++++++++++++ monitor.h | 20 +++++++++++++++++++ 8 files changed, 132 insertions(+), 15 deletions(-) create mode 100644 cars.cpp create mode 100644 cars.h create mode 100644 monitor.cpp create mode 100644 monitor.h diff --git a/DataStructureProject.pro b/DataStructureProject.pro index d6558e9..8423d43 100644 --- a/DataStructureProject.pro +++ b/DataStructureProject.pro @@ -25,10 +25,14 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + monitor.cpp \ + cars.cpp HEADERS += \ - mainwindow.h + mainwindow.h \ + monitor.h \ + cars.h FORMS += \ mainwindow.ui diff --git a/cars.cpp b/cars.cpp new file mode 100644 index 0000000..727fc41 --- /dev/null +++ b/cars.cpp @@ -0,0 +1,9 @@ +#include "cars.h" +#include + +Cars::Cars(QWidget *parent) : QWidget(parent) +{ + m_color = rand() % 3; +} + + diff --git a/cars.h b/cars.h new file mode 100644 index 0000000..b9a528a --- /dev/null +++ b/cars.h @@ -0,0 +1,24 @@ +#ifndef CARS_H +#define CARS_H + +#include +#include +#include + +class Cars : public QWidget +{ + Q_OBJECT +private: + enum Color m_color; + QPixmap m_pixmap; + QString m_number; +public: + enum Color { Pink, Red, Yellow } + explicit Cars(QWidget *parent = nullptr); + explicit Cars(Color color, QWidget *parenet = nullptr); +signals: + +public slots: +}; + +#endif // CARS_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 49d64fc..895aae0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,14 +1,34 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include "monitor.h" +#include +#include +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - ui->setupUi(this); + resize(1800, 800); + //ui->setupUi(this); + + montior = new Monitor(this); + QPixmap pix(":/cars/yellow"); + QPainter painter(this); + painter.drawPixmap(0,0,pix); + QPixmap pix2=pix.scaled(QSize(50,50)); + painter.drawPixmap(0,0,pix2); } MainWindow::~MainWindow() { delete ui; + delete montior; +} + +void MainWindow::open(void) { + QDialog dialog; + dialog.setWindowTitle(tr("Hello, dialog!")); + dialog.exec(); } diff --git a/mainwindow.h b/mainwindow.h index a3948a9..7099819 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include namespace Ui { class MainWindow; @@ -13,10 +14,13 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = 0); + void open(void); ~MainWindow(); private: Ui::MainWindow *ui; + QAction *action; + Monitor *montor; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 6050363..fa3e268 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1,24 +1,43 @@ + MainWindow - - + + 0 0 - 400 - 300 + 1800 + 800 - - MainWindow + + 停车场管理系统 - - - - + + + + false + + + + 0 + 0 + 1800 + 26 + + + + + + TopToolBarArea + + + false + + + - - + diff --git a/monitor.cpp b/monitor.cpp new file mode 100644 index 0000000..84a38f1 --- /dev/null +++ b/monitor.cpp @@ -0,0 +1,17 @@ +#include "monitor.h" +#include + +Monitor::Monitor(QWidget *parent) : QWidget(parent) +{ + resize(800, 600); +} + +void Monitor::paintEvent(QPaintEvent *) { + QPainter painter(this); + painter.drawLine(80, 100, 650, 500); + painter.setPen(Qt::red); + painter.drawRect(10, 10, 100, 400); + painter.setPen(QPen(Qt::green, 5)); + painter.setBrush(Qt::blue); + painter.drawEllipse(50, 150, 400, 200); +} diff --git a/monitor.h b/monitor.h new file mode 100644 index 0000000..f16fce5 --- /dev/null +++ b/monitor.h @@ -0,0 +1,20 @@ +#ifndef MONITOR_H +#define MONITOR_H + +#include + +class Monitor : public QWidget +{ + Q_OBJECT +public: + explicit Monitor(QWidget *parent = nullptr); + +protected: + void paintEvent(QPaintEvent *); + +signals: + +public slots: +}; + +#endif // MONITOR_H