亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問在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 關注
  • 2934 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號