//控制死窗体 int width = this->geometry().width(); int height = this->geometry().height(); this->setFixedSize(width,height);
//定时器的使用 QTimer *serialReadTimer = new QTimer;
connect(serialReadTimer,SIGNAL(timeout()),this,SLOT(readSerial())); serialReadTimer->start(100);
// set display color size QBrush myBrush; QPalette myPalette; myBrush = QBrush(Qt::red,Qt::DiagCrossPattern); myPalette.setBrush(QPalette::Text,myBrush); ui->showDatabase->setPalette(myPalette); ui->showDatabase->setFont(QFont("Timers",16));
1 2 //qSqlTableModel tableView的使用 3 model = new QSqlTableModel(this,db); 4 model->setTable("node"); 5 //手动提交 6 model->setEditStrategy(QSqlTableModel::OnManualSubmit); 7 //修改tableView的列名 8 model->setHeaderData(4,Qt::Orientation::Horizontal,"state"); 9 model->select(); 10 ui->showDatabase->setModel(model); 11 //根据内容自适应 12 ui->showDatabase->resizeColumnsToContents(); 13 //hide header id 14 QHeaderView *headerView = ui->showDatabase->verticalHeader(); 15 headerView->setHidden(true); 16 17 //关闭数据库 18 db.close();