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

QT中qsqltablemodel类怎么设置居中显示


翻翻过去那场雪
浏览 2896回答 4
4回答

隔江千里

用qsqltablemodel的insetrow()、setdata()、submitall()函数实现增;  &nbsp;officeTable->insertRow(0);  &nbsp;officeTable->setData(officeTable->index(0,&nbsp;0),&nbsp;row);  &nbsp;officeTable->setData(officeTable->index(0,&nbsp;1),&nbsp;newWnd->imageFileEditor->currentIndex());  &nbsp;officeTable->setData(officeTable->index(0,&nbsp;2),&nbsp;newWnd->locationText->text());  &nbsp;officeTable->setData(officeTable->index(0,&nbsp;3),&nbsp;newWnd->countryText->currentText());  &nbsp;officeTable->setData(officeTable->index(0,&nbsp;4),&nbsp;newWnd->descriptionEditor->toPlainText());  &nbsp;officeTable->submitAll();&nbsp;用removerow()、submitall()函数实现删;  &nbsp;int&nbsp;officeCount&nbsp;=&nbsp;officeTable->rowCount();  &nbsp;officeTable->removeRow(id);  &nbsp;for(int&nbsp;i&nbsp;=&nbsp;id;&nbsp;i&nbsp;<&nbsp;officeCount&nbsp;-&nbsp;1;i++)  &nbsp;{  &nbsp; officeTable->setData(officeTable->index(i,&nbsp;0),&nbsp;i);  &nbsp;}  &nbsp;officeTable->submitAll();用QSqlRecord类的setvalue实现改;  &nbsp; QSqlRecord&nbsp;recordCurrentRow&nbsp;=&nbsp;officeTable->record(id);  &nbsp; recordCurrentRow.setValue("id",&nbsp;id&nbsp;-&nbsp;1);  &nbsp; officeTable->setRecord(id&nbsp;-&nbsp;1,&nbsp;recordCurrentRow);  &nbsp; officeTable->submitAll();&nbsp;用QSqlRecord类的.value进行比较实现查;  int&nbsp;Dialog::findArtistId(const&nbsp;QString&nbsp;&artist)  {  &nbsp; &nbsp; QSqlTableModel&nbsp;*artistModel&nbsp;=&nbsp;model->relationModel(2);&nbsp; &nbsp; int&nbsp;row&nbsp;=&nbsp;0;&nbsp;  &nbsp; &nbsp; while&nbsp;(row&nbsp;<&nbsp;artistModel->rowCount())&nbsp;{  &nbsp; &nbsp; &nbsp; &nbsp; QSqlRecord&nbsp;record&nbsp;=&nbsp;artistModel->record(row);  &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp;(record.value("artist")&nbsp;==&nbsp;artist)  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return&nbsp;record.value("id").toInt();  &nbsp; &nbsp; &nbsp; &nbsp; else  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; row++;  &nbsp; &nbsp; }  &nbsp; &nbsp; return&nbsp;addNewArtist(artist);}&nbsp;
打开App,查看更多内容
随时随地看视频慕课网APP