master #3

Merged
ccsens_zhangsan merged 6 commits from bailijun/qt_qcp_show:master into master 4 years ago
  1. 24
      QCPShow.pro.user
  2. BIN
      image/1LED_gray.png
  3. BIN
      image/1LED_green.png
  4. 6
      main.cpp
  5. 67
      mainwidget.cpp
  6. 6
      mainwidget.h
  7. 32
      mainwidget.ui
  8. 2
      resource.qrc
  9. 3
      websocketservice.cpp

24
QCPShow.pro.user

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.1, 2021-10-19T16:47:12. -->
<!-- Written by QtCreator 4.2.1, 2021-10-21T10:14:57. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{fe03815e-74e2-457e-b60c-e66368cd4ce4}</value>
<value type="QByteArray">{0d351c1e-abb6-427c-8d0b-30ca23826ed5}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -66,7 +66,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -90,7 +90,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -106,7 +106,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -144,7 +144,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -160,7 +160,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -198,7 +198,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -214,7 +214,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -231,7 +231,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
@ -286,13 +286,13 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QCPShow</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">QCPShow2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/QtSpace/QCPShow/QCPShow.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Qt/QtSpace/qt_qcp_show/QCPShow.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QCPShow.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

BIN
image/1LED_gray.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
image/1LED_green.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

6
main.cpp

@ -25,11 +25,11 @@ int main(int argc, char *argv[])
//绑定信号与槽
QObject::connect(&websocketService,&WebsocketService::wsConnectedStatusChanged,
&w,MainWidget::onWsConnectedStatusChanged);
&w,&MainWidget::onWsConnectedStatusChanged);
QObject::connect(&websocketService,&WebsocketService::newPatientMergencyInfo,
&w,MainWidget::onNewPatientMergencyInfo);
&w,&MainWidget::onNewPatientMergencyInfo);
QObject::connect(&websocketService,&WebsocketService::patientMergencyStatusChanged,
&w,MainWidget::onPatientMergencyStatusChanged);
&w,&MainWidget::onPatientMergencyStatusChanged);
QObject::connect(&w,&MainWidget::statusChanged,&httpService,&HttpService::updateStatus);

67
mainwidget.cpp

@ -22,6 +22,7 @@ MainWidget::MainWidget(QWidget *parent) :
info->realCountDownInSeconds--;
}
}
updateUi();
});
//切换病人
@ -38,22 +39,22 @@ MainWidget::MainWidget(QWidget *parent) :
ui->statusLabel->setText("Not Connected");
//显示设置
QFont font1, font2;
font1.setPointSize(150);
font2.setPointSize(20);
font1.setPointSize(240);
font2.setPointSize(240);
font3.setPointSize(20);
ui->textLabel->setFont(font1);
ui->countdownLabel->setFont(font1);
ui->statusLabel->setFont(font2);
ui->countdownLabel->setFont(font2);
ui->statusLabel->setFont(font3);
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);
// ui->textLabel->setAlignment(Qt::AlignHCenter);
// ui->countdownLabel->setAlignment(Qt::AlignHCenter);
// ui->statusLabel->setAlignment(Qt::AlignRight);
m_curX = 0;
connect(&m_lableScrollTimer,SIGNAL(timeout()),this,SLOT(lableScrollDisplay()));
m_lableScrollTimer.start(10);
}
MainWidget::~MainWidget()
@ -63,11 +64,19 @@ MainWidget::~MainWidget()
void MainWidget::updateUi()
{
m_curX = 0;//内容超出显示区域时,更新患者信息显示从头开始滚动
//更新statusLabel
ui->statusLabel->setText(QString("%1 | %2")
.arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接")
.arg(m_patientEmergencyInfos.length())
);
// ui->statusLabel->setText(QString("%1 | %2")
// .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接")
// .arg(m_patientEmergencyInfos.length())
// );
if(m_wsConnectedStatus){
ui->LEDLabel->setStyleSheet("border-image: url(:/image/1LED_green.png);");
}else{
ui->LEDLabel->setStyleSheet("border-image: url(::/image/1LED_gray.png);");
}
ui->statusLabel->setText(QString::number(m_patientEmergencyInfos.length()));
if(m_patientEmergencyInfos.length() == 0){
//不显示
@ -89,7 +98,8 @@ void MainWidget::updateUi()
int hour,min,sec,nTotalSecs;
nTotalSecs = pInfo->realCountDownInSeconds;
sec = nTotalSecs % 60;
min = nTotalSecs / 60 % 60;
// min = nTotalSecs / 60 % 60;
min = nTotalSecs / 60 ; //min显示大于60
hour = nTotalSecs / 3600;
QString str = QString("%1:%2").arg(min,2,10,QLatin1Char('0')).arg(sec,2,10,QLatin1Char('0'));
ui->countdownLabel->setText(str);
@ -111,9 +121,28 @@ 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);
// ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2);
ui->countdownLabel->setGeometry(0,(this->height()-30)/2,this->width(),(this->height()-30)/2);
ui->LEDLabel->setGeometry(this->width()-120,this->height()-30,20,30);
ui->statusLabel->setGeometry(this->width()-80,this->height()-30,20,30);
}
void MainWidget::lableScrollDisplay()
{
QFontMetrics fm(font1);
m_width = fm.width(ui->textLabel->text());
if(this->width() > m_width){
ui->textLabel->setGeometry((this->width()-m_width)/2, 0,m_width,(this->height()-30)/2);
}
else{
m_curX ++;
ui->textLabel->setGeometry(20-m_curX,0,m_width,(this->height()-30)/2);
// qDebug()<<"move" <<m_curX;
}
if(m_curX > (m_width - this->width())){
m_curX = 0;
}
}
void MainWidget::onWsConnectedStatusChanged(int status)

6
mainwidget.h

@ -28,6 +28,9 @@ private:
QTimer m_countDownTimer;
QTimer m_switchPatientTimer;
int m_wsConnectedStatus;
QFont font1, font2, font3;
QTimer m_lableScrollTimer;
int m_width, m_curX;
public slots:
void updateUi();
@ -36,9 +39,10 @@ public slots:
void onPatientMergencyStatusChanged(QString firstAidId,QString time,QString status);
void addPatientToList(PatientEmergencyInfo *);
void deletePatientFromList(QString firstAidId);
void lableScrollDisplay();
signals:
statusChanged(QString firstAidId,QString status);
void statusChanged(QString firstAidId,QString status);
};
#endif // MAINWIDGET_H

32
mainwidget.ui

@ -23,13 +23,16 @@
</rect>
</property>
<property name="text">
<string>textLabel</string>
<string>传控科技优先做CT</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="countdownLabel">
<property name="geometry">
<rect>
<x>390</x>
<x>210</x>
<y>160</y>
<width>721</width>
<height>61</height>
@ -38,14 +41,17 @@
<property name="text">
<string>countdownLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="statusLabel">
<property name="geometry">
<rect>
<x>1010</x>
<x>950</x>
<y>390</y>
<width>91</width>
<height>20</height>
<width>151</width>
<height>21</height>
</rect>
</property>
<property name="font">
@ -56,6 +62,22 @@
<property name="text">
<string>statusLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="LEDLabel">
<property name="geometry">
<rect>
<x>790</x>
<y>400</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>

2
resource.qrc

@ -2,5 +2,7 @@
<qresource prefix="/">
<file>image/header.png</file>
<file>image/black_bg.jpg</file>
<file>image/1LED_gray.png</file>
<file>image/1LED_green.png</file>
</qresource>
</RCC>

3
websocketservice.cpp

@ -115,10 +115,11 @@ void WebsocketService::onTextMessageReceived(const QString &message)
void WebsocketService::handleWsButtonStartMsg(QJsonObject jobj)
{
qDebug()<<jobj;
QString firstAidId = jobj.take("firstAidId").toString();
QString name = jobj.take("name").toString();
QString content = jobj.take("content").toString();
quint64 realCountdown = jobj.take("realCountdown").toInt(0) / 1000;
quint64 realCountdown = jobj.take("realCountdown").toString().toInt(0) / 1000;
emit newPatientMergencyInfo(firstAidId,name,content,realCountdown);
}

Loading…
Cancel
Save