diff --git a/image/black_bg.jpg b/image/black_bg.jpg new file mode 100644 index 0000000..1c6576a Binary files /dev/null and b/image/black_bg.jpg differ diff --git a/main.cpp b/main.cpp index 063c36a..31d9c45 100644 --- a/main.cpp +++ b/main.cpp @@ -33,7 +33,8 @@ int main(int argc, char *argv[]) QObject::connect(&w,&MainWidget::statusChanged,&httpService,&HttpService::updateStatus); - w.show(); +// w.show(); + w.showFullScreen(); return a.exec(); } diff --git a/mainwidget.cpp b/mainwidget.cpp index 3acfebd..e0b2b41 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -36,6 +36,24 @@ MainWidget::MainWidget(QWidget *parent) : //显示连接状态 ui->statusLabel->setText("Not Connected"); + + //显示设置 + QFont font1, font2; + font1.setPointSize(150); + font2.setPointSize(20); + ui->textLabel->setFont(font1); + ui->countdownLabel->setFont(font1); + ui->statusLabel->setFont(font2); + ui->textLabel->setStyleSheet("QLabel {color: rgb(255,0,0);}");//设置文本红色 + ui->countdownLabel->setStyleSheet("QLabel {color: rgb(255,0,0);}");//设置文本红色 + ui->statusLabel->setStyleSheet("QLabel {color: rgb(85,255,0);}");//设置文本绿色 + ui->textLabel->setAlignment(Qt::AlignHCenter); + ui->countdownLabel->setAlignment(Qt::AlignHCenter); + ui->statusLabel->setAlignment(Qt::AlignRight); + ui->textLabel->setAlignment(Qt::AlignCenter); + ui->countdownLabel->setAlignment(Qt::AlignCenter); + ui->statusLabel->setAlignment(Qt::AlignCenter); + } MainWidget::~MainWidget() @@ -77,6 +95,27 @@ void MainWidget::updateUi() ui->countdownLabel->setText(str); } +void MainWidget::paintEvent(QPaintEvent *event) +{ + //设置背景图片 + QPainter p(this); + p.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/black_bg.jpg")); +// qDebug() << "MainWidget::paintEvent"; + + //重新调整label字体大小 + //TODO +} + +void MainWidget::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + //标题 + ui->textLabel->setGeometry(0,0,this->width(),(this->height()-20)/2); + ui->countdownLabel->setGeometry(0,(this->height()-20)/2,this->width(),(this->height()-20)/2); + ui->statusLabel->setGeometry(0,this->height()-16,this->width(),20); +} + void MainWidget::onWsConnectedStatusChanged(int status) { qDebug() << "MainWidget::onWsConnectedStatusChanged " << status; diff --git a/mainwidget.h b/mainwidget.h index c58b13b..e4d6280 100644 --- a/mainwidget.h +++ b/mainwidget.h @@ -4,6 +4,7 @@ #include #include "patientemergencyinfo.h" #include +#include namespace Ui { class MainWidget; @@ -16,6 +17,8 @@ class MainWidget : public QWidget public: explicit MainWidget(QWidget *parent = 0); ~MainWidget(); + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); private: Ui::MainWidget *ui; diff --git a/mainwidget.ui b/mainwidget.ui index f5ccf4c..7da9a5c 100644 --- a/mainwidget.ui +++ b/mainwidget.ui @@ -48,6 +48,11 @@ 20 + + + 20 + + statusLabel diff --git a/resource.qrc b/resource.qrc index e137aa3..de84d0a 100644 --- a/resource.qrc +++ b/resource.qrc @@ -1,5 +1,6 @@ image/header.png + image/black_bg.jpg