本文整理汇总了C++中QSqlTableModel::removeRow方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlTableModel::removeRow方法的具体用法?C++ QSqlTableModel::removeRow怎么用?C++ QSqlTableModel::removeRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlTableModel
的用法示例。
在下文中一共展示了QSqlTableModel::removeRow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteRow
void Browser::deleteRow()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
if (!model)
return;
QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
for (int i = 0; i < currentSelection.count(); ++i) {
if (currentSelection.at(i).column() != 0)
continue;
model->removeRow(currentSelection.at(i).row());
}
updateActions();
}
示例2: decreaseAlbumCount
void MainWindow::decreaseAlbumCount(QModelIndex artistIndex)
{
int row = artistIndex.row();
QModelIndex albumCountIndex = artistIndex.sibling(row, 2);
int albumCount = albumCountIndex.data().toInt();
QSqlTableModel *artists = model->relationModel(2);
if (albumCount == 1) {
artists->removeRow(row);
showImageLabel();
} else {
artists->setData(albumCountIndex, QVariant(albumCount - 1));
}
}
示例3:
void Form::on_pushButton_2_clicked()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(ui->treeView->model());
if (!model)
return;
QModelIndexList currentSelection = ui->treeView->selectionModel()->selectedIndexes();
for (int i = 0; i < currentSelection.count(); ++i) {
if (currentSelection.at(i).column() != 0)
continue;
model->removeRow(currentSelection.at(i).row());
}
}
示例4: deleteRow
void FenPrincipale::deleteRow()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(tablemesures->model());
if (!model)
return;
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
QModelIndexList currentSelection = tablemesures->selectionModel()->selectedIndexes();
for (int i = 0; i < currentSelection.count(); ++i) {
if (currentSelection.at(i).column() != 0)
continue;
model->removeRow(currentSelection.at(i).row());
}
model->submitAll();
model->setEditStrategy(QSqlTableModel ::OnManualSubmit);
}
示例5: deleteRowss
void FenPrincipale::deleteRowss()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(tabless->model());
if (!model)
return;
QModelIndexList currentSelection = tabless->selectionModel()->selectedIndexes();
for (int i = 0; i < currentSelection.count(); ++i) {
if (currentSelection.at(i).column() != 0)
continue;
model->removeRow(currentSelection.at(i).row());
//tabless->edit();
deleteRow();
}
}
示例6: tr
//插入一条记录
void
Widget::CStudentDialog::insertRecord()
{
bool ok;
QString name = m_pNameEdit->text();
QString Sex = m_pSexEdit->text();
double age = m_pAgeEdit->text().toDouble( &ok );
if( !ok ){
QMessageBox::warning( this , "错误" , "请重新填写年龄" );
return;
}
QString number = m_pNumberEdit->text();
QString post = m_pPostEdit->text();
QSqlTableModel table;
table.setTable( "person" );
table.select();
QSqlRecord record;
record = table.record();
record.setValue( "name" , name );
record.setValue( "gender" , Sex );
record.setValue( "age" , age );
ok = table.insertRecord( -1, record );
if( !ok ){
AddStudentError
}
table.submitAll();
table.setTable( "person" );
table.setFilter( tr("name = '%0'").arg( name ) );
qDebug() << table.select();
int id = table.record(0).value( Enum::PersonSection::Person_id ).toInt( &ok );
if( !ok ){
table.removeRow( 0 );
table.submitAll();
AddStudentError
}
示例7: deleteUserInfo
void loginFrame::deleteUserInfo()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("Registry.db");
if(!db.open())
return;
QSqlTableModel *model = new QSqlTableModel();
model->setTable("userlist");
model->select();
//删除相应行
model->removeRow(ui->comboBox->currentIndex());
model->submitAll();
//修正combobox的显示
RegistyShowID.removeAt(ui->comboBox->currentIndex());
ui->comboBox->removeItem(ui->comboBox->currentIndex());
ui->comboBox->setCurrentIndex(0);
for(int i=0;i<model->rowCount();i++)
{
ui->comboBox->setIconSize(QSize(20,20));
ui->comboBox->setItemIcon(i,QIcon(":/images/head.png"));
ui->comboBox->setItemText(i,RegistyShowID.at(i).id);
}
}
示例8: removeSelectedRows
void TableEditor::removeSelectedRows()
{
int currentTab = tabWidget->currentIndex();
QTableView *tv = agentsTable;
QSqlTableModel *stm = agentsModel;
QString table = "agents";
int idColumn = 0;
if (currentTab == 1)
{
tv = determinationsTable;
stm = determinationsModel;
table = "determinations";
}
else if (currentTab == 2)
{
tv = imagesTable;
stm = imagesModel;
table = "images";
idColumn = 20;
}
else if (currentTab == 3)
{
tv = taxaTable;
stm = taxaModel;
table = "taxa";
idColumn = 1;
}
else if (currentTab == 4)
{
tv = organismsTable;
stm = organismsModel;
table = "organisms";
}
else if (currentTab == 5)
{
tv = sensuTable;
stm = sensuModel;
table = "sensu";
}
QItemSelectionModel *selected = tv->selectionModel();
QModelIndexList rowList = selected->selectedIndexes();
for (int i = rowList.count()-1; i >= 0; i--)
{
stm->removeRow(rowList.at(i).row(), rowList.at(i).parent());
QString identifier;
if (table == "determinations")
{
QString orgID = stm->data(stm->index(rowList.at(i).row(),0),Qt::DisplayRole).toString();
QString date = stm->data(stm->index(rowList.at(i).row(),2),Qt::DisplayRole).toString();
QString tsnID = stm->data(stm->index(rowList.at(i).row(),4),Qt::DisplayRole).toString();
QString source = stm->data(stm->index(rowList.at(i).row(),5),Qt::DisplayRole).toString();
reversions.append("INSERT OR REPLACE INTO determinations SELECT * FROM pub_determinations "
"WHERE dsw_identified = '" + orgID + "' AND "
"dwc_dateIdentified = '" + date + "' AND "
"tsnID = '" + tsnID + "' AND "
"nameAccordingToID = '" + source + "' LIMIT 1");
}
else
{
identifier = stm->data(stm->index(rowList.at(i).row(),idColumn),Qt::DisplayRole).toString();
reversions.append("INSERT OR REPLACE INTO " + table + " SELECT * FROM pub_" + table + " WHERE dcterms_identifier = '" + identifier + "' LIMIT 1");
}
}
}