| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include "widget.h"
- #include <QApplication>
- #include "dataupdatethread.h"
- #include "buttonclickthread.h"
- #include <QScreen>
- #include <QGraphicsScene>
- #include <QGraphicsView>
- #include "pdu_ctrl.h"
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- //窗口初始化
- pdu_Ctrl::instance();
- Widget w;
- qDebug()<<"widget End";
- QGraphicsScene *scene = new QGraphicsScene;
- QGraphicsView *gview = new QGraphicsView(scene);
- QGraphicsProxyWidget *g_proxy_widget;
- qDebug()<<"x:"<<w.size().width()<<"y:"<<w.size().height();
- QScreen *desktop = QApplication::primaryScreen();
- QRect screen_info = desktop->geometry();
- // Rotation 90 degree
- g_proxy_widget = scene->addWidget((QWidget*)&w);
- g_proxy_widget->setRotation(0);
- // Set window size
- w.resize(screen_info.width(), screen_info.height());
- qDebug()<<"Rect:x="<<screen_info.width()<<"y="<<screen_info.height();
- pdu_Ctrl::instance()->InitData(&w,g_proxy_widget,gview,screen_info.width(), screen_info.height());
- gview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- gview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- gview->setStyleSheet("border:none");
- gview->showFullScreen();
- qDebug()<<"x:"<<w.size().width()<<"y:"<<w.size().height();
- qDebug()<<"Thread start";
- QString appDirPath = QCoreApplication::applicationDirPath();
- pdu_Ctrl::instance()->strSqliteAddress=appDirPath+"/pdu_dat.db";
- pdu_Ctrl::instance()->ReadModbusInit();
- //============================线程开启====================================
- //数据更新线程
- DataUpdateThread thread_Update(nullptr);
- thread_Update.pwidget=&w;
- //QString appDirPath = QCoreApplication::applicationDirPath();
- //thread_Update.strSqliteAddress=appDirPath+"/pdu_dat.db";
- thread_Update.initShm();
- thread_Update.start();
- //GPIO更新线程
- ButtonClickThread thread_Button(nullptr);
- thread_Button.InitConnect();
- thread_Button.start();
- //thread_Button.InitConnect();
- int ret=a.exec();
- //析构
- thread_Update.isRunStats=false;
- thread_Update.wait();
- thread_Button.isRunning=false;
- thread_Button.wait();
- pdu_Ctrl::distory();
- return ret;
- }
|