为了账号安全,请及时绑定邮箱和手机立即绑定

请问在QT中qsqltablemodel类怎么设置居中显示?

请问在QT中qsqltablemodel类怎么设置居中显示?

翻翻过去那场雪 2019-07-01 10:06:51
QT中qsqltablemodel类怎么设置居中显示
查看完整描述

4 回答

?
隔江千里

TA贡献1906条经验 获得超10个赞

  • 用qsqltablemodel的insetrow()、setdata()、submitall()函数实现增;

   officeTable->insertRow(0);

   officeTable->setData(officeTable->index(0, 0), row);

   officeTable->setData(officeTable->index(0, 1), newWnd->imageFileEditor->currentIndex());

   officeTable->setData(officeTable->index(0, 2), newWnd->locationText->text());

   officeTable->setData(officeTable->index(0, 3), newWnd->countryText->currentText());

   officeTable->setData(officeTable->index(0, 4), newWnd->descriptionEditor->toPlainText());

   officeTable->submitAll();

 

  • 用removerow()、submitall()函数实现删;

   int officeCount = officeTable->rowCount();

   officeTable->removeRow(id);

   for(int i = id; i < officeCount - 1;i++)

   {

    officeTable->setData(officeTable->index(i, 0), i);

   }

   officeTable->submitAll();


  • 用QSqlRecord类的setvalue实现改;

    QSqlRecord recordCurrentRow = officeTable->record(id);

    recordCurrentRow.setValue("id", id - 1);

    officeTable->setRecord(id - 1, recordCurrentRow);

    officeTable->submitAll();

 

  • 用QSqlRecord类的.value进行比较实现查;

  int Dialog::findArtistId(const QString &artist)

  {

      QSqlTableModel *artistModel = model->relationModel(2);

    int row = 0;

 

      while (row < artistModel->rowCount()) {

          QSqlRecord record = artistModel->record(row);

          if (record.value("artist") == artist)

              return record.value("id").toInt();

          else

              row++;

      }

      return addNewArtist(artist);

}

 





查看完整回答
反对 回复 2019-07-14
  • 4 回答
  • 0 关注
  • 2878 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信