From c30ae1e12d871118b0b7449e7351dfc5d2fe5bff Mon Sep 17 00:00:00 2001 From: XinJiang1 <1170701029@qq.com> Date: Wed, 25 Dec 2024 23:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E5=8C=96=E4=BA=86ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- camera.cpp | 10 +- cotton_double2.pro.user | 2 +- main.cpp | 7 + styles/style.qss | 119 +++++++++++ ui_widget.h | 309 +++++++++++++++++---------- widget.cpp | 86 ++++---- widget.h | 6 +- widget.ui | 459 +++++++++++++++++++++------------------- 8 files changed, 617 insertions(+), 381 deletions(-) create mode 100644 styles/style.qss diff --git a/camera.cpp b/camera.cpp index 2090d52..ab170e7 100644 --- a/camera.cpp +++ b/camera.cpp @@ -518,9 +518,6 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr) bool DestoryCamera() { - MdigProcess(MilDigitizer0, MilGrabBufferList0, 20, M_STOP, M_DEFAULT,ProcessingFunction0, M_NULL); - MdigProcess(MilDigitizer1, MilGrabBufferList1, 20, M_STOP, M_DEFAULT,ProcessingFunction1, M_NULL); - for (int i = 0; i < 20; i++) { MbufFree(MilGrabBufferList0[i]); @@ -1049,6 +1046,9 @@ bool iniLowMac() bool DestoryLowMac() { + MdigProcess(MilDigitizer0, MilGrabBufferList0, 20, M_STOP, M_DEFAULT,ProcessingFunction0, M_NULL); + MdigProcess(MilDigitizer1, MilGrabBufferList1, 20, M_STOP, M_DEFAULT,ProcessingFunction1, M_NULL); + // 构建停止命令 uint8_t stop_command[9] = {0}; stop_command[0] = 0xAA; // 起始标志 @@ -1166,10 +1166,10 @@ void Start_camera() { cout << "Error: Unable to write to lower machine for start command." << endl; } - - } + + std::vector > expandArray(const std::vector > &array, int newCols) { int rows = array.size(); diff --git a/cotton_double2.pro.user b/cotton_double2.pro.user index bd7523d..ec1d34b 100644 --- a/cotton_double2.pro.user +++ b/cotton_double2.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/main.cpp b/main.cpp index f672255..f90ade8 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,13 @@ int main(int argc, char *argv[]) // 安装自定义消息处理器,保存原始处理器 originalHandler = qInstallMessageHandler(customMessageHandler); + // QFile file("C:/Users/Administrator/Documents/cotton_double/styles/style.qss"); // 或者使用文件路径 + // if (file.open(QFile::ReadOnly)) { + // QString styleSheet = QLatin1String(file.readAll()); + // qApp->setStyleSheet(styleSheet); + // } + + Widget w; w.show(); return a.exec(); diff --git a/styles/style.qss b/styles/style.qss new file mode 100644 index 0000000..e96bedd --- /dev/null +++ b/styles/style.qss @@ -0,0 +1,119 @@ +/* style.qss */ + +/* 全局字体设置 */ +* { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 48px; /* 全局字体大小 */ + font-weight: bold; /* 全局字体粗细 */ + color: #FFFFFF; /* 全局文字颜色,白色 */ +} + +/* QWidget 样式 */ +QWidget { + background-color: #2C3E50; /* 深灰色背景 */ + border-radius: 15px; /* 圆角半径 */ +} + +/* QPushButton 样式 */ +QPushButton { + background-color: #3498DB; /* 蓝色按钮背景 */ + color: #FFFFFF; /* 白色按钮文字 */ + border: 2px solid #7F8C8D; /* 中灰色边框 */ + padding: 20px 40px; /* 内边距 */ + border-radius: 12px; /* 圆角半径 */ + /* 去除伪状态样式 */ +} + +/* QGroupBox 样式 */ +QGroupBox { + border: 2px solid #7F8C8D; /* 中灰色边框 */ + border-radius: 12px; /* 圆角半径 */ + margin-top: 30px; /* 标题上边距 */ + background-color: #2C3E50; /* 深灰色背景 */ +} + +QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; + padding: 0 10px; + color: #FFFFFF; /* 白色标题文字 */ + font-size: 48px; /* 标题字体大小 */ +} + +/* QCheckBox 样式 */ +QCheckBox { + spacing: 20px; /* 图标与文字间距 */ + color: #FFFFFF; /* 白色文字 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 字体粗细 */ +} + +QCheckBox::indicator { + width: 48px; + height: 48px; +} + +QCheckBox::indicator::unchecked { + border: 3px solid #7F8C8D; /* 中灰色边框 */ + border-radius: 12px; /* 圆角半径 */ + background: #2C3E50; /* 深灰色背景 */ +} + +QCheckBox::indicator::checked { + border: 3px solid #3498DB; /* 蓝色边框 */ + border-radius: 12px; /* 圆角半径 */ + background: #3498DB; /* 蓝色背景 */ +} + +QCheckBox::indicator::checked::after { + content: "\2713"; /* 勾选符号 */ + color: #FFFFFF; /* 勾选符号颜色 */ + font-size: 48px; /* 勾选符号大小 */ + position: absolute; + top: -12px; + left: 12px; +} + +/* QSpinBox 样式 */ +QSpinBox, QDoubleSpinBox { + background-color: #3498DB; /* 蓝色背景 */ + border: 2px solid #7F8C8D; /* 中灰色边框 */ + border-radius: 12px; /* 圆角半径 */ + padding: 20px; /* 内边距 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 字体粗细 */ + color: #FFFFFF; /* 文字颜色 */ +} + +QSpinBox::up-button, QSpinBox::down-button, +QDoubleSpinBox::up-button, QDoubleSpinBox::down-button { + background-color: #2C3E50; /* 深灰色按钮背景 */ + border: none; + width: 60px; + height: 60px; + border-radius: 12px; /* 圆角半径 */ +} + +QSpinBox::up-button::arrow, QSpinBox::down-button::arrow, +QDoubleSpinBox::up-button::arrow, QDoubleSpinBox::down-button::arrow { + width: 24px; + height: 24px; + color: #FFFFFF; /* 箭头颜色 */ +} + +/* QLabel 样式 */ +QLabel { + color: #FFFFFF; /* 白色文字 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 字体粗细 */ +} + +/* 消息框样式 */ +QLabel#message { + background-color: #E67E22; /* 橙色背景 */ + color: #FFFFFF; /* 白色文字 */ + padding: 20px; + border-radius: 12px; + font-size: 48px; + font-weight: bold; +} diff --git a/ui_widget.h b/ui_widget.h index 6c46fc5..3b70f7f 100644 --- a/ui_widget.h +++ b/ui_widget.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -32,26 +31,17 @@ public: QHBoxLayout *horizontalLayout; QTabWidget *tabWidget; QWidget *tab; - QVBoxLayout *verticalLayout; - QGroupBox *groupBox_5; - QGridLayout *gridLayout; - QPushButton *btn_goto_sort; - QPushButton *btn_0to3; - QPushButton *pushButtonStart; - QPushButton *pushButton_2; - QGroupBox *groupBox; - QHBoxLayout *horizontalLayout_2; QLabel *label; - QLabel *lab_lowermachine_isconnect; - QPushButton *btn_reconnect; + QLabel *label_3; QWidget *tab_2; QHBoxLayout *horizontalLayout_3; QGroupBox *groupBox_7; QVBoxLayout *verticalLayout_3; QLabel *lab_info; QPushButton *btn_start; - QPushButton *btn_take_photos; QPushButton *btn_stop; + QPushButton *btn_take_photos; + QPushButton *btn_set_valve; QPushButton *btn_quit; QSpacerItem *verticalSpacer; QFrame *frame_6; @@ -90,6 +80,7 @@ public: QSpinBox *spinbox_delaytime; QSpinBox *spinbox_encoder; QSpinBox *spinbox_valve; + QPushButton *btn_tab3_backtab2; QLabel *label_title_4; QGroupBox *groupBox_2; QLabel *label_explosure_2; @@ -105,86 +96,23 @@ public: { if (Widget->objectName().isEmpty()) Widget->setObjectName("Widget"); - Widget->resize(1817, 1047); + Widget->resize(2173, 1117); horizontalLayout = new QHBoxLayout(Widget); horizontalLayout->setObjectName("horizontalLayout"); tabWidget = new QTabWidget(Widget); tabWidget->setObjectName("tabWidget"); tabWidget->setEnabled(true); + tabWidget->setStyleSheet(QString::fromUtf8("background-color: rgb(228, 223, 186);")); tab = new QWidget(); tab->setObjectName("tab"); - verticalLayout = new QVBoxLayout(tab); - verticalLayout->setObjectName("verticalLayout"); - groupBox_5 = new QGroupBox(tab); - groupBox_5->setObjectName("groupBox_5"); - gridLayout = new QGridLayout(groupBox_5); - gridLayout->setObjectName("gridLayout"); - btn_goto_sort = new QPushButton(groupBox_5); - btn_goto_sort->setObjectName("btn_goto_sort"); - - gridLayout->addWidget(btn_goto_sort, 2, 0, 1, 1); - - btn_0to3 = new QPushButton(groupBox_5); - btn_0to3->setObjectName("btn_0to3"); - - gridLayout->addWidget(btn_0to3, 2, 1, 1, 1); - - pushButtonStart = new QPushButton(groupBox_5); - pushButtonStart->setObjectName("pushButtonStart"); - - gridLayout->addWidget(pushButtonStart, 1, 0, 1, 1); - - pushButton_2 = new QPushButton(groupBox_5); - pushButton_2->setObjectName("pushButton_2"); - - gridLayout->addWidget(pushButton_2, 1, 1, 1, 1); - - - verticalLayout->addWidget(groupBox_5); - - groupBox = new QGroupBox(tab); - groupBox->setObjectName("groupBox"); - horizontalLayout_2 = new QHBoxLayout(groupBox); - horizontalLayout_2->setObjectName("horizontalLayout_2"); - horizontalLayout_2->setSizeConstraint(QLayout::SizeConstraint::SetDefaultConstraint); - label = new QLabel(groupBox); + label = new QLabel(tab); label->setObjectName("label"); - - horizontalLayout_2->addWidget(label); - - lab_lowermachine_isconnect = new QLabel(groupBox); - lab_lowermachine_isconnect->setObjectName("lab_lowermachine_isconnect"); - QPalette palette; - QBrush brush(QColor(237, 212, 0, 255)); - brush.setStyle(Qt::SolidPattern); - palette.setBrush(QPalette::Active, QPalette::Button, brush); - palette.setBrush(QPalette::Active, QPalette::Base, brush); - palette.setBrush(QPalette::Active, QPalette::Window, brush); - QBrush brush1(QColor(246, 233, 127, 255)); - brush1.setStyle(Qt::SolidPattern); - palette.setBrush(QPalette::Active, QPalette::AlternateBase, brush1); - palette.setBrush(QPalette::Inactive, QPalette::Button, brush); - palette.setBrush(QPalette::Inactive, QPalette::Base, brush); - palette.setBrush(QPalette::Inactive, QPalette::Window, brush); - palette.setBrush(QPalette::Inactive, QPalette::AlternateBase, brush1); - palette.setBrush(QPalette::Disabled, QPalette::Button, brush); - palette.setBrush(QPalette::Disabled, QPalette::Base, brush); - palette.setBrush(QPalette::Disabled, QPalette::Window, brush); - palette.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1); - lab_lowermachine_isconnect->setPalette(palette); - - horizontalLayout_2->addWidget(lab_lowermachine_isconnect); - - btn_reconnect = new QPushButton(groupBox); - btn_reconnect->setObjectName("btn_reconnect"); - - horizontalLayout_2->addWidget(btn_reconnect); - - - verticalLayout->addWidget(groupBox); - - verticalLayout->setStretch(0, 5); - verticalLayout->setStretch(1, 1); + label->setGeometry(QRect(330, 120, 1271, 131)); + label->setStyleSheet(QString::fromUtf8("font: 72pt \"Microsoft YaHei UI\";")); + label_3 = new QLabel(tab); + label_3->setObjectName("label_3"); + label_3->setGeometry(QRect(500, 260, 1151, 141)); + label_3->setStyleSheet(QString::fromUtf8("font: 72pt \"Microsoft YaHei UI\";")); tabWidget->addTab(tab, QString()); tab_2 = new QWidget(); tab_2->setObjectName("tab_2"); @@ -201,36 +129,192 @@ public: lab_info->setObjectName("lab_info"); lab_info->setEnabled(true); QFont font; - font.setPointSize(28); + font.setFamilies({QString::fromUtf8("Microsoft YaHei UI")}); + font.setPointSize(48); + font.setBold(false); + font.setItalic(false); lab_info->setFont(font); + lab_info->setStyleSheet(QString::fromUtf8("font: 48pt \"Microsoft YaHei UI\";\n" +"color: rgb(34, 40, 49);")); verticalLayout_3->addWidget(lab_info); btn_start = new QPushButton(groupBox_7); btn_start->setObjectName("btn_start"); - btn_start->setMinimumSize(QSize(70, 200)); - btn_start->setStyleSheet(QString::fromUtf8("font: 700 40pt \"Microsoft YaHei UI\";")); + btn_start->setMinimumSize(QSize(70, 170)); + btn_start->setStyleSheet(QString::fromUtf8("/* btn_start \346\240\267\345\274\217 */\n" +"QPushButton#btn_start {\n" +" background-color: #4b5b47; /* \346\232\227\347\273\277\350\211\262\350\203\214\346\231\257 */\n" +" color: #f5efe7; /* \347\231\275\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #145A32; /* \346\233\264\346\267\261\347\232\204\347\273\277\350\211\262\350\276\271\346\241\206 */\n" +" padding: 20px 40px; /* \345\206\205\350\276\271\350\267\235 */\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */\n" +" font-size: 48px; /* \345\255\227\344\275\223\345\244\247\345\260\217 */\n" +" font-weight: bold; /* \347\262\227\344\275\223\345\255\227 */\n" +" font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; /* \345\255\227\344\275\223\346\227\217 */\n" +"}\n" +"\n" +"QPushButton#btn_start:hover {\n" +" background-color: #28b45d; /* \347\250\215\344\272\256\347\232\204\346\232\227\347\273\277\350\211\262\350\203\214\346\231\257 */\n" +" " + " border: 2px solid #1f8a4d; /* \346\232\227\347\273\277\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_start:pressed {\n" +" background-color: #186a3b; /* \346\233\264\346\267\261\347\232\204\347\273\277\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #134d33; /* \346\233\264\346\267\261\347\232\204\347\273\277\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_start:disabled {\n" +" background-color: #7F8C8D; /* \347\201\260\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #7F8C8D; /* \347\201\260\350\211\262\350\276\271\346\241\206 */\n" +"}")); verticalLayout_3->addWidget(btn_start); - btn_take_photos = new QPushButton(groupBox_7); - btn_take_photos->setObjectName("btn_take_photos"); - btn_take_photos->setMinimumSize(QSize(70, 200)); - btn_take_photos->setStyleSheet(QString::fromUtf8("font: 700 40pt \"Microsoft YaHei UI\";")); - - verticalLayout_3->addWidget(btn_take_photos); - btn_stop = new QPushButton(groupBox_7); btn_stop->setObjectName("btn_stop"); - btn_stop->setMinimumSize(QSize(70, 200)); - btn_stop->setStyleSheet(QString::fromUtf8("font: 700 40pt \"Microsoft YaHei UI\";")); + btn_stop->setMinimumSize(QSize(70, 170)); + btn_stop->setStyleSheet(QString::fromUtf8("/* btn_stop \346\240\267\345\274\217 */\n" +"QPushButton#btn_stop\n" +" {\n" +" background-color: #be9970; /* \346\232\227\347\272\242\350\211\262\350\203\214\346\231\257 */\n" +" color: #ffffff; /* \347\231\275\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #641e16; /* \346\233\264\346\267\261\347\232\204\347\272\242\350\211\262\350\276\271\346\241\206 */\n" +" padding: 20px 40px; /* \345\206\205\350\276\271\350\267\235 */\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */\n" +" font-size: 48px; /* \345\255\227\344\275\223\345\244\247\345\260\217 */\n" +" font-weight: bold; /* \347\262\227\344\275\223\345\255\227 */\n" +" font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; /* \345\255\227\344\275\223\346\227\217 */\n" +"}\n" +"\n" +"QPushButton#btn_stop:hover {\n" +" background-color: #cb4335; /* \347\250\215\344\272\256\347\232\204\346\232\227\347\272\242\350\211\262\350\203\214\346\231\257 */\n" +"" + " border: 2px solid #a93226; /* \346\232\227\347\272\242\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_stop:pressed {\n" +" background-color: #7b241c; /* \346\233\264\346\267\261\347\232\204\347\272\242\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #641e16; /* \346\233\264\346\267\261\347\232\204\347\272\242\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_stop:disabled {\n" +" background-color: #7F8C8D; /* \347\201\260\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #7F8C8D; /* \347\201\260\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"")); verticalLayout_3->addWidget(btn_stop); + btn_take_photos = new QPushButton(groupBox_7); + btn_take_photos->setObjectName("btn_take_photos"); + btn_take_photos->setMinimumSize(QSize(70, 170)); + btn_take_photos->setStyleSheet(QString::fromUtf8("/* btn_take_photos \346\240\267\345\274\217 */\n" +"QPushButton#btn_take_photos {\n" +" background-color: #7c8876; /* \346\232\227\350\223\235\350\211\262\350\203\214\346\231\257 */\n" +" color: #ffffff; /* \347\231\275\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #145a86; /* \346\233\264\346\267\261\347\232\204\350\223\235\350\211\262\350\276\271\346\241\206 */\n" +" padding: 20px 40px; /* \345\206\205\350\276\271\350\267\235 */\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */\n" +" font-size: 48px; /* \345\255\227\344\275\223\345\244\247\345\260\217 */\n" +" font-weight: bold; /* \347\262\227\344\275\223\345\255\227 */\n" +" font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; /* \345\255\227\344\275\223\346\227\217 */\n" +"}\n" +"\n" +"QPushButton#btn_take_photos:hover {\n" +" background-color: #2e86c1; /* \347\250\215\344\272\256\347\232\204\346\232\227\350\223\235\350\211\262\350\203\214\346" + "\231\257 */\n" +" border: 2px solid #21618c; /* \346\232\227\350\223\235\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_take_photos:pressed {\n" +" background-color: #145a86; /* \346\233\264\346\267\261\347\232\204\350\223\235\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #0f3b6b; /* \346\233\264\346\267\261\347\232\204\350\223\235\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_take_photos:disabled {\n" +" background-color: #7F8C8D; /* \347\201\260\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #7F8C8D; /* \347\201\260\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"")); + + verticalLayout_3->addWidget(btn_take_photos); + + btn_set_valve = new QPushButton(groupBox_7); + btn_set_valve->setObjectName("btn_set_valve"); + btn_set_valve->setMinimumSize(QSize(0, 170)); + btn_set_valve->setStyleSheet(QString::fromUtf8("/* btn_set_value \346\240\267\345\274\217 */\n" +"QPushButton#btn_set_valve {\n" +" background-color: #be9970; /* \346\251\231\350\211\262\350\203\214\346\231\257 */\n" +" color: #ffffff; /* \347\231\275\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #d68910; /* \346\267\261\346\251\231\350\211\262\350\276\271\346\241\206 */\n" +" padding: 20px 40px; /* \345\206\205\350\276\271\350\267\235 */\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */\n" +" font-size: 48px; /* \345\255\227\344\275\223\345\244\247\345\260\217 */\n" +" font-weight: bold; /* \347\262\227\344\275\223\345\255\227 */\n" +" font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; /* \345\255\227\344\275\223\346\227\217 */\n" +"}\n" +"\n" +"QPushButton#btn_set_valve:hover {\n" +" background-color: #f1c40f; /* \344\272\256\346\251\231\350\211\262\350\203\214\346\231\257 */\n" +" border: 2px solid #f39c12; /* \346\251\231\350\211\262\350" + "\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_set_valve:pressed {\n" +" background-color: #d68910; /* \346\267\261\346\251\231\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #b9770e; /* \346\233\264\346\267\261\347\232\204\346\251\231\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_set_valve:disabled {\n" +" background-color: #7F8C8D; /* \347\201\260\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #7F8C8D; /* \347\201\260\350\211\262\350\276\271\346\241\206 */\n" +"}")); + + verticalLayout_3->addWidget(btn_set_valve); + btn_quit = new QPushButton(groupBox_7); btn_quit->setObjectName("btn_quit"); - btn_quit->setMinimumSize(QSize(70, 200)); - btn_quit->setStyleSheet(QString::fromUtf8("font: 700 40pt \"Microsoft YaHei UI\";")); + btn_quit->setMinimumSize(QSize(70, 170)); + btn_quit->setStyleSheet(QString::fromUtf8("/* btn_quit \346\240\267\345\274\217 */\n" +"QPushButton#btn_quit {\n" +" background-color: #716244; /* \347\272\242\350\211\262\350\203\214\346\231\257 */\n" +" color: #ffffff; /* \347\231\275\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #922b21; /* \346\267\261\347\272\242\350\211\262\350\276\271\346\241\206 */\n" +" padding: 20px 40px; /* \345\206\205\350\276\271\350\267\235 */\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */\n" +" font-size: 48px; /* \345\255\227\344\275\223\345\244\247\345\260\217 */\n" +" font-weight: bold; /* \347\262\227\344\275\223\345\255\227 */\n" +" font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; /* \345\255\227\344\275\223\346\227\217 */\n" +"}\n" +"\n" +"QPushButton#btn_quit:hover {\n" +" background-color: #e74c3c; /* \344\272\256\347\272\242\350\211\262\350\203\214\346\231\257 */\n" +" border: 2px solid #c0392b; /* \347\272\242\350\211\262\350\276\271\346\241" + "\206 */\n" +"}\n" +"\n" +"QPushButton#btn_quit:pressed {\n" +" background-color: #922b21; /* \346\267\261\347\272\242\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #641e16; /* \346\233\264\346\267\261\347\232\204\347\272\242\350\211\262\350\276\271\346\241\206 */\n" +"}\n" +"\n" +"QPushButton#btn_quit:disabled {\n" +" background-color: #7F8C8D; /* \347\201\260\350\211\262\350\203\214\346\231\257 */\n" +" color: #BDC3C7; /* \347\201\260\350\211\262\346\226\207\345\255\227 */\n" +" border: 2px solid #7F8C8D; /* \347\201\260\350\211\262\350\276\271\346\241\206 */\n" +"}")); verticalLayout_3->addWidget(btn_quit); @@ -304,7 +388,9 @@ public: sizePolicy.setHeightForWidth(camera_1_img->sizePolicy().hasHeightForWidth()); camera_1_img->setSizePolicy(sizePolicy); camera_1_img->setStyleSheet(QString::fromUtf8("background-color: rgb(129, 129, 129);\n" -"border: 4px solid black;")); +"border: 4px solid black;\n" +"\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */")); camera_1_img->setLineWidth(1); verticalLayout_2->addWidget(camera_1_img); @@ -366,7 +452,8 @@ public: sizePolicy.setHeightForWidth(camera_0_img->sizePolicy().hasHeightForWidth()); camera_0_img->setSizePolicy(sizePolicy); camera_0_img->setStyleSheet(QString::fromUtf8("background-color: rgb(129, 129, 129);\n" -"border: 4px solid black;")); +"border: 4px solid black;\n" +" border-radius: 12px; /* \345\234\206\350\247\222\345\215\212\345\276\204 */")); camera_0_img->setLineWidth(1); verticalLayout_2->addWidget(camera_0_img); @@ -398,7 +485,7 @@ public: "border-color: rgb(0, 0, 0);")); btn_set_lower = new QPushButton(groupBox_4); btn_set_lower->setObjectName("btn_set_lower"); - btn_set_lower->setGeometry(QRect(480, 470, 231, 141)); + btn_set_lower->setGeometry(QRect(30, 470, 231, 141)); frame_3 = new QFrame(groupBox_4); frame_3->setObjectName("frame_3"); frame_3->setGeometry(QRect(20, 80, 698, 373)); @@ -460,6 +547,9 @@ public: horizontalLayout_6->addLayout(verticalLayout_4); + btn_tab3_backtab2 = new QPushButton(groupBox_4); + btn_tab3_backtab2->setObjectName("btn_tab3_backtab2"); + btn_tab3_backtab2->setGeometry(QRect(480, 470, 231, 141)); label_title_4 = new QLabel(tab_3); label_title_4->setObjectName("label_title_4"); label_title_4->setGeometry(QRect(920, 150, 91, 21)); @@ -506,21 +596,15 @@ public: void retranslateUi(QWidget *Widget) { Widget->setWindowTitle(QCoreApplication::translate("Widget", "Widget", nullptr)); - groupBox_5->setTitle(QCoreApplication::translate("Widget", "GroupBox", nullptr)); - btn_goto_sort->setText(QCoreApplication::translate("Widget", "\345\201\234\346\255\242", nullptr)); - btn_0to3->setText(QCoreApplication::translate("Widget", "\345\226\267\351\230\200\346\265\213\350\257\225", nullptr)); - pushButtonStart->setText(QCoreApplication::translate("Widget", "\345\274\200\345\247\213", nullptr)); - pushButton_2->setText(QCoreApplication::translate("Widget", "\344\277\235\345\255\230\345\233\276\347\211\207", nullptr)); - groupBox->setTitle(QCoreApplication::translate("Widget", "\350\277\236\346\216\245\347\212\266\346\200\201\357\274\232", nullptr)); - label->setText(QCoreApplication::translate("Widget", "\344\270\213\344\275\215\346\234\272", nullptr)); - lab_lowermachine_isconnect->setText(QString()); - btn_reconnect->setText(QCoreApplication::translate("Widget", "\351\207\215\346\226\260\350\277\236\346\216\245", nullptr)); + label->setText(QCoreApplication::translate("Widget", "\345\245\216\345\261\257\351\223\266\345\212\233\346\243\211\346\262\271\346\234\272\346\242\260\346\234\211\351\231\220\345\205\254\345\217\270", nullptr)); + label_3->setText(QCoreApplication::translate("Widget", "\347\261\275\346\243\211\345\274\202\347\272\244\346\235\202\350\264\250\345\210\206\351\200\211\346\234\272", nullptr)); tabWidget->setTabText(tabWidget->indexOf(tab), QCoreApplication::translate("Widget", "Tab 1", nullptr)); groupBox_7->setTitle(QCoreApplication::translate("Widget", "\346\216\247\345\210\266\345\217\212\347\212\266\346\200\201", nullptr)); lab_info->setText(QCoreApplication::translate("Widget", "\347\212\266\346\200\201", nullptr)); btn_start->setText(QCoreApplication::translate("Widget", "\345\274\200\345\247\213\345\210\206\351\200\211", nullptr)); - btn_take_photos->setText(QCoreApplication::translate("Widget", "\346\212\223\345\217\226\345\233\276\347\211\207", nullptr)); btn_stop->setText(QCoreApplication::translate("Widget", "\345\201\234\346\255\242\345\210\206\351\200\211", nullptr)); + btn_take_photos->setText(QCoreApplication::translate("Widget", "\346\212\223\345\217\226\345\233\276\347\211\207", nullptr)); + btn_set_valve->setText(QCoreApplication::translate("Widget", "\350\256\276\347\275\256\345\217\202\346\225\260", nullptr)); btn_quit->setText(QCoreApplication::translate("Widget", "\351\200\200\345\207\272\347\263\273\347\273\237", nullptr)); label_2->setText(QCoreApplication::translate("Widget", "\347\233\270\346\234\2721\357\274\210\351\253\230\344\276\247/\346\260\224\347\275\220\344\276\247\357\274\211", nullptr)); dl_enable_1->setText(QCoreApplication::translate("Widget", "\345\261\217\350\224\275\346\267\261\345\272\246\345\255\246\344\271\240", nullptr)); @@ -543,6 +627,7 @@ public: label_delaytime->setText(QCoreApplication::translate("Widget", "\345\273\266\350\277\237\346\227\266\351\227\264", nullptr)); label_encoder->setText(QCoreApplication::translate("Widget", "\347\233\270\346\234\272\350\241\214\351\242\221", nullptr)); label_encoder_2->setText(QCoreApplication::translate("Widget", "\345\226\267\351\230\200\351\242\221\347\216\207", nullptr)); + btn_tab3_backtab2->setText(QCoreApplication::translate("Widget", "\350\277\224\345\233\236", nullptr)); label_title_4->setText(QCoreApplication::translate("Widget", "\345\226\267\351\230\200\346\265\213\350\257\225\347\225\214\351\235\242", nullptr)); groupBox_2->setTitle(QCoreApplication::translate("Widget", "\346\211\213\345\212\250\345\226\267\351\230\200\346\265\213\350\257\225", nullptr)); label_explosure_2->setText(QCoreApplication::translate("Widget", "\351\200\232\351\201\223", nullptr)); diff --git a/widget.cpp b/widget.cpp index 6ae3fd5..3d6a40f 100644 --- a/widget.cpp +++ b/widget.cpp @@ -52,6 +52,8 @@ Widget::Widget(QWidget *parent) QTimer* timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &Widget::refreshImage); timer->start(50); // 每50毫秒秒刷新一次界面 + + ui->tabWidget->setCurrentIndex(1); } Widget::~Widget() @@ -252,26 +254,10 @@ void Widget::on_pushButton_2_clicked() SaveImg_Flag = 1; } -void Widget::on_btn_goto_sort_clicked() -{ - // 回复显示的图片 - { - QMutexLocker locker(&gDispPicMutex0); - gDispCurrentPicId0 = 0; - } - ui->camera_0_img->clear(); - { - QMutexLocker locker(&gDispPicMutex1); - gDispCurrentPicId1 = 0; - } - ui->camera_1_img->clear(); - DestoryCamera(); - DestoryLowMac(); -} - - void Widget::on_btn_stop_clicked() { + DestoryLowMac(); + this->isCamRunning = false; // 恢复显示的图片 { @@ -284,31 +270,6 @@ void Widget::on_btn_stop_clicked() gDispCurrentPicId1 = 0; } ui->camera_1_img->clear(); - // 停止检测工作者线程 - for(int i = 0; i < 2; ++i) - { - g_recognitionRunning[i]->store(false); - g_img_Queue[i]->stop(); // 停止队列以唤醒线程 - } - - // 等待检测工作者线程结束 - for(int i = 0; i < 2; ++i) - { - if(g_recognitionThread[i] && g_recognitionThread[i]->joinable()) - { - g_recognitionThread[i]->join(); - delete g_recognitionThread[i]; - g_recognitionThread[i] = nullptr; - } - - if(g_recognitionRunning[i]) - { - delete g_recognitionRunning[i]; - g_recognitionRunning[i] = nullptr; - } - } - DestoryCamera(); - DestoryLowMac(); } @@ -362,6 +323,33 @@ void Widget::on_btn_take_photos_released() void Widget::on_btn_quit_clicked() { + // 停止检测工作者线程 + for(int i = 0; i < 2; ++i) + { + g_recognitionRunning[i]->store(false); + g_img_Queue[i]->stop(); // 停止队列以唤醒线程 + } + + // 等待检测工作者线程结束 + for(int i = 0; i < 2; ++i) + { + if(g_recognitionThread[i] && g_recognitionThread[i]->joinable()) + { + g_recognitionThread[i]->join(); + delete g_recognitionThread[i]; + g_recognitionThread[i] = nullptr; + } + + if(g_recognitionRunning[i]) + { + delete g_recognitionRunning[i]; + g_recognitionRunning[i] = nullptr; + } + } + + DestoryCamera(); + DestoryLowMac(); + qApp->quit(); } @@ -375,3 +363,15 @@ void Widget::on_btn_set_lower_clicked() file_valve = ui->spinbox_valve->text().toInt(); // 阀门通道 } + +void Widget::on_btn_set_valve_clicked() +{ + ui->tabWidget->setCurrentIndex(2); +} + + +void Widget::on_btn_tab3_backtab2_clicked() +{ + ui->tabWidget->setCurrentIndex(1); +} + diff --git a/widget.h b/widget.h index 34d0125..2776456 100644 --- a/widget.h +++ b/widget.h @@ -32,8 +32,6 @@ private slots: void on_pushButton_2_clicked(); - void on_btn_goto_sort_clicked(); - void on_btn_stop_clicked(); void on_btn_start_clicked(); @@ -46,6 +44,10 @@ private slots: void on_btn_set_lower_clicked(); + void on_btn_set_valve_clicked(); + + void on_btn_tab3_backtab2_clicked(); + private: Ui::Widget *ui; diff --git a/widget.ui b/widget.ui index e149637..2455c21 100644 --- a/widget.ui +++ b/widget.ui @@ -6,8 +6,8 @@ 0 0 - 1817 - 1047 + 2173 + 1117 @@ -19,6 +19,9 @@ true + + background-color: rgb(228, 223, 186); + 1 @@ -26,196 +29,38 @@ Tab 1 - - - - - GroupBox - - - - - - 停止 - - - - - - - 喷阀测试 - - - - - - - 开始 - - - - - - - 保存图片 - - - - - - - - - - 连接状态: - - - - QLayout::SizeConstraint::SetDefaultConstraint - - - - - 下位机 - - - - - - - - - - - - 237 - 212 - 0 - - - - - - - 237 - 212 - 0 - - - - - - - 237 - 212 - 0 - - - - - - - 246 - 233 - 127 - - - - - - - - - 237 - 212 - 0 - - - - - - - 237 - 212 - 0 - - - - - - - 237 - 212 - 0 - - - - - - - 246 - 233 - 127 - - - - - - - - - 237 - 212 - 0 - - - - - - - 237 - 212 - 0 - - - - - - - 237 - 212 - 0 - - - - - - - 246 - 233 - 127 - - - - - - - - - - - - - - - 重新连接 - - - - - - - + + + + 330 + 120 + 1271 + 131 + + + + font: 72pt "Microsoft YaHei UI"; + + + 奎屯银力棉油机械有限公司 + + + + + + 500 + 260 + 1151 + 141 + + + + font: 72pt "Microsoft YaHei UI"; + + + 籽棉异纤杂质分选机 + + @@ -253,9 +98,16 @@ - 28 + Microsoft YaHei UI + 48 + false + false + + font: 48pt "Microsoft YaHei UI"; +color: rgb(34, 40, 49); + 状态 @@ -266,59 +118,214 @@ 70 - 200 + 170 - font: 700 40pt "Microsoft YaHei UI"; + /* btn_start 样式 */ +QPushButton#btn_start { + background-color: #4b5b47; /* 暗绿色背景 */ + color: #f5efe7; /* 白色文字 */ + border: 2px solid #145A32; /* 更深的绿色边框 */ + padding: 20px 40px; /* 内边距 */ + border-radius: 12px; /* 圆角半径 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 粗体字 */ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; /* 字体族 */ +} + +QPushButton#btn_start:hover { + background-color: #28b45d; /* 稍亮的暗绿色背景 */ + border: 2px solid #1f8a4d; /* 暗绿色边框 */ +} + +QPushButton#btn_start:pressed { + background-color: #186a3b; /* 更深的绿色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #134d33; /* 更深的绿色边框 */ +} + +QPushButton#btn_start:disabled { + background-color: #7F8C8D; /* 灰色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #7F8C8D; /* 灰色边框 */ +} 开始分选 - - - - - 70 - 200 - - - - font: 700 40pt "Microsoft YaHei UI"; - - - 抓取图片 - - - 70 - 200 + 170 - font: 700 40pt "Microsoft YaHei UI"; + /* btn_stop 样式 */ +QPushButton#btn_stop + { + background-color: #be9970; /* 暗红色背景 */ + color: #ffffff; /* 白色文字 */ + border: 2px solid #641e16; /* 更深的红色边框 */ + padding: 20px 40px; /* 内边距 */ + border-radius: 12px; /* 圆角半径 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 粗体字 */ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; /* 字体族 */ +} + +QPushButton#btn_stop:hover { + background-color: #cb4335; /* 稍亮的暗红色背景 */ + border: 2px solid #a93226; /* 暗红色边框 */ +} + +QPushButton#btn_stop:pressed { + background-color: #7b241c; /* 更深的红色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #641e16; /* 更深的红色边框 */ +} + +QPushButton#btn_stop:disabled { + background-color: #7F8C8D; /* 灰色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #7F8C8D; /* 灰色边框 */ +} + 停止分选 + + + + + 70 + 170 + + + + /* btn_take_photos 样式 */ +QPushButton#btn_take_photos { + background-color: #7c8876; /* 暗蓝色背景 */ + color: #ffffff; /* 白色文字 */ + border: 2px solid #145a86; /* 更深的蓝色边框 */ + padding: 20px 40px; /* 内边距 */ + border-radius: 12px; /* 圆角半径 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 粗体字 */ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; /* 字体族 */ +} + +QPushButton#btn_take_photos:hover { + background-color: #2e86c1; /* 稍亮的暗蓝色背景 */ + border: 2px solid #21618c; /* 暗蓝色边框 */ +} + +QPushButton#btn_take_photos:pressed { + background-color: #145a86; /* 更深的蓝色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #0f3b6b; /* 更深的蓝色边框 */ +} + +QPushButton#btn_take_photos:disabled { + background-color: #7F8C8D; /* 灰色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #7F8C8D; /* 灰色边框 */ +} + + + + + 抓取图片 + + + + + + + + 0 + 170 + + + + /* btn_set_value 样式 */ +QPushButton#btn_set_valve { + background-color: #be9970; /* 橙色背景 */ + color: #ffffff; /* 白色文字 */ + border: 2px solid #d68910; /* 深橙色边框 */ + padding: 20px 40px; /* 内边距 */ + border-radius: 12px; /* 圆角半径 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 粗体字 */ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; /* 字体族 */ +} + +QPushButton#btn_set_valve:hover { + background-color: #f1c40f; /* 亮橙色背景 */ + border: 2px solid #f39c12; /* 橙色边框 */ +} + +QPushButton#btn_set_valve:pressed { + background-color: #d68910; /* 深橙色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #b9770e; /* 更深的橙色边框 */ +} + +QPushButton#btn_set_valve:disabled { + background-color: #7F8C8D; /* 灰色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #7F8C8D; /* 灰色边框 */ +} + + + 设置参数 + + + 70 - 200 + 170 - font: 700 40pt "Microsoft YaHei UI"; + /* btn_quit 样式 */ +QPushButton#btn_quit { + background-color: #716244; /* 红色背景 */ + color: #ffffff; /* 白色文字 */ + border: 2px solid #922b21; /* 深红色边框 */ + padding: 20px 40px; /* 内边距 */ + border-radius: 12px; /* 圆角半径 */ + font-size: 48px; /* 字体大小 */ + font-weight: bold; /* 粗体字 */ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; /* 字体族 */ +} + +QPushButton#btn_quit:hover { + background-color: #e74c3c; /* 亮红色背景 */ + border: 2px solid #c0392b; /* 红色边框 */ +} + +QPushButton#btn_quit:pressed { + background-color: #922b21; /* 深红色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #641e16; /* 更深的红色边框 */ +} + +QPushButton#btn_quit:disabled { + background-color: #7F8C8D; /* 灰色背景 */ + color: #BDC3C7; /* 灰色文字 */ + border: 2px solid #7F8C8D; /* 灰色边框 */ +} 退出系统 @@ -445,7 +452,9 @@ background-color: rgb(129, 129, 129); -border: 4px solid black; +border: 4px solid black; + + border-radius: 12px; /* 圆角半径 */ 1 @@ -559,7 +568,8 @@ border: 4px solid black; background-color: rgb(129, 129, 129); -border: 4px solid black; +border: 4px solid black; + border-radius: 12px; /* 圆角半径 */ 1 @@ -621,7 +631,7 @@ border-color: rgb(0, 0, 0); - 480 + 30 470 231 141 @@ -732,6 +742,19 @@ border-color: rgb(0, 0, 0); + + + + 480 + 470 + 231 + 141 + + + + 返回 + +