一、
1 void DocM::inital() 2 { 3 mp_lable_dbstatus = new QLabel(this); 4 mp_lable_ret = new QLabel(this); 5 mp_lable_statistic = new QLabel(this); 6 mp_btn_dbstatus = new QPushButton(this); 7 mp_btn_dbstatus->setEnabled(false); 8 QString str = QString::number(DbUtil::getInstance().getBookCount()); 9 mp_lable_statistic->setText(QString::fromLocal8Bit("系统中图书数量:%1 册").arg(str)); 10 mp_lable_statistic->setStyleSheet("background-color: rgb(211, 211, 211);"); 11 12 QFont pret; 13 pret.setBold(true); 14 mp_lable_ret->setFont(pret); 15 mp_lable_ret->setStyleSheet("QLabel{color:rgb(66, 133, 245);}"); 16 mp_lable_ret->setText(QString::fromLocal8Bit("匹配书籍:20册")); 17 18 19 mp_btn_dbstatus->setMaximumHeight(25); 20 mp_btn_dbstatus->setMaximumWidth(25); 21 mp_btn_dbstatus->setMask(QRegion(0, 0, 22, 22, QRegion::Ellipse)); 22 23 QFont font = mp_btn_dbstatus->font(); 24 font.setPointSize(8); 25 mp_btn_dbstatus->setFont(font); 26 mp_btn_dbstatus->setStyleSheet("background-color: rgb(0, 255, 0);"); 27 mp_btn_dbstatus->setText(QString::fromLocal8Bit("正常")); 28 if (DbUtil::getInstance().check()) 29 { 30 mp_btn_dbstatus->setStyleSheet("background-color: rgb(0, 255, 0);"); 31 mp_btn_dbstatus->setText(QString::fromLocal8Bit("正常")); 32 } 33 else 34 { 35 mp_btn_dbstatus->setStyleSheet("background-color: rgb(255, 0, 0);"); 36 mp_btn_dbstatus->setText(QString::fromLocal8Bit("断开")); 37 } 38 39 40 mp_lable_dbstatus->setText(QString::fromLocal8Bit("数据库连接:")); 41 42 ui.statusBar->addWidget(mp_lable_statistic); 43 ui.statusBar->addWidget(mp_lable_ret); 44 ui.statusBar->addPermanentWidget(mp_lable_dbstatus); 45 ui.statusBar->addPermanentWidget(mp_btn_dbstatus); 46 47 ui.pb_search->setStyleSheet("background-color: rgb(220, 220, 220);"); 48 49 ui.tbv_show->horizontalHeader()->setHighlightSections(false); 50 QFont fh_header = ui.tbv_show->horizontalHeader()->font(); 51 fh_header.setFamily("song"); 52 fh_header.setPointSize(14); 53 fh_header.setBold(true); 54 ui.tbv_show->horizontalHeader()->setFont(fh_header); 55 ui.tbv_show->horizontalHeader()->setStyleSheet("QHeaderView::section{background:DimGray;color:rgb(255, 255, 255)}"); 56 ui.tbv_show->horizontalHeader()->setSortIndicatorShown(true); 57 ui.tbv_show->horizontalHeader()->setSortIndicator(0, Qt::SortOrder::AscendingOrder); 58 ui.tbv_show->verticalHeader()->setStyleSheet("QHeaderView::section{background:white; color:black;}"); 59 QFont fv_header = ui.tbv_show->verticalHeader()->font(); 60 fv_header.setFamily("song"); 61 fv_header.setPointSize(10); 62 ui.tbv_show->verticalHeader()->setFont(fv_header); 63 64 ui.tbv_show->hide(); 65 ui.tbv_show->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); 66 mp_lable_ret->hide(); 67 } 68
1 void DocM::inital() 2 { 3 mp_lable_dbstatus = new QLabel(this); 4 mp_lable_ret = new QLabel(this); 5 mp_lable_statistic = new QLabel(this); 6 mp_btn_dbstatus = new QPushButton(this); 7 mp_btn_dbstatus->setEnabled(false); 8 QString str = QString::number(DbUtil::getInstance().getBookCount()); 9 mp_lable_statistic->setText(QString::fromLocal8Bit("系统中图书数量:%1 册").arg(str)); 10 mp_lable_statistic->setStyleSheet("background-color: rgb(211, 211, 211);"); 11 12 QFont pret; 13 pret.setBold(true); 14 mp_lable_ret->setFont(pret); 15 mp_lable_ret->setStyleSheet("QLabel{color:rgb(66, 133, 245);}"); 16 mp_lable_ret->setText(QString::fromLocal8Bit("匹配书籍:20册")); 17 18 19 mp_btn_dbstatus->setMaximumHeight(25); 20 mp_btn_dbstatus->setMaximumWidth(25); 21 mp_btn_dbstatus->setMask(QRegion(0, 0, 22, 22, QRegion::Ellipse)); 22 23 QFont font = mp_btn_dbstatus->font(); 24 font.setPointSize(8); 25 mp_btn_dbstatus->setFont(font); 26 mp_btn_dbstatus->setStyleSheet("background-color: rgb(0, 255, 0);"); 27 mp_btn_dbstatus->setText(QString::fromLocal8Bit("正常")); 28 if (DbUtil::getInstance().check()) 29 { 30 mp_btn_dbstatus->setStyleSheet("background-color: rgb(0, 255, 0);"); 31 mp_btn_dbstatus->setText(QString::fromLocal8Bit("正常")); 32 } 33 else 34 { 35 mp_btn_dbstatus->setStyleSheet("background-color: rgb(255, 0, 0);"); 36 mp_btn_dbstatus->setText(QString::fromLocal8Bit("断开")); 37 } 38 39 40 mp_lable_dbstatus->setText(QString::fromLocal8Bit("数据库连接:")); 41 42 ui.statusBar->addWidget(mp_lable_statistic); 43 ui.statusBar->addWidget(mp_lable_ret); 44 ui.statusBar->addPermanentWidget(mp_lable_dbstatus); 45 ui.statusBar->addPermanentWidget(mp_btn_dbstatus); 46 47 ui.pb_search->setStyleSheet("background-color: rgb(220, 220, 220);"); 48 49 ui.tbv_show->horizontalHeader()->setHighlightSections(false); 50 QFont fh_header = ui.tbv_show->horizontalHeader()->font(); 51 fh_header.setFamily("song"); 52 fh_header.setPointSize(14); 53 fh_header.setBold(true); 54 ui.tbv_show->horizontalHeader()->setFont(fh_header); 55 ui.tbv_show->horizontalHeader()->setStyleSheet("QHeaderView::section{background:DimGray;color:rgb(255, 255, 255)}"); 56 ui.tbv_show->horizontalHeader()->setSortIndicatorShown(true); 57 ui.tbv_show->horizontalHeader()->setSortIndicator(0, Qt::SortOrder::AscendingOrder); 58 ui.tbv_show->verticalHeader()->setStyleSheet("QHeaderView::section{background:white; color:black;}"); 59 QFont fv_header = ui.tbv_show->verticalHeader()->font(); 60 fv_header.setFamily("song"); 61 fv_header.setPointSize(10); 62 ui.tbv_show->verticalHeader()->setFont(fv_header); 63 64 ui.tbv_show->hide(); 65 ui.tbv_show->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); 66 mp_lable_ret->hide(); 67 } 68