本文整理汇总了C++中QSqlTableModel::insertRow方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlTableModel::insertRow方法的具体用法?C++ QSqlTableModel::insertRow怎么用?C++ QSqlTableModel::insertRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlTableModel
的用法示例。
在下文中一共展示了QSqlTableModel::insertRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importData
void MainWindow::importData()
{
int exam_id;
QString dataFileName = QFileDialog::getOpenFileName(this,tr("Import Data From a CSV File"),QDir::homePath(),tr("CSV File (*.csv)"));
if(dataFileName.isEmpty())
return;
QFile dataFile(dataFileName);
if(!dataFile.open(QIODevice::ReadOnly))
{
QMessageBox::critical(this,tr("Open File Failed"),tr("Cannot open selected file"));;
return;
}
QSqlTableModel* student = m_scoreView->studentListModel();
QSqlTableModel* exam = m_scoreView->examListModel();
QSqlRelationalTableModel* score = m_scoreView->scoreListModel();
QFileInfo tmp(dataFileName);
QString exam_name = tmp.baseName();
exam->setFilter(QString("name = \'%1\'").arg(exam_name));
if(exam->rowCount() == 1)
{
QSqlRecord rq = exam->record(0);
exam_id = rq.value("id").toInt();
}
else
{
exam->insertRow(0);
exam->setData(exam->index(0,Global::Exam_Name),exam_name);
exam->submitAll();
exam->setFilter(QString("name = \'%1\'").arg(exam_name));
QSqlRecord rq = exam->record(0);
exam_id = rq.value("id").toInt();
}
QHash<QString,int> studentMap;
for(int row = 0;row < student->rowCount();++row)
studentMap.insert(student->data(student->index(row,1)).toString(),student->data(student->index(row,0)).toInt());
QTextStream in(&dataFile);
QString record = in.readLine();
QStringList candidate_seps;
candidate_seps << ";" << "," << "\t" << " ";
QString real_sep;
bool is_legal = false;
QStringList cols;
foreach(real_sep, candidate_seps)
{
cols = record.split(real_sep);
if(cols.size() == 11)
{
is_legal = true;
break;
}
}
示例2: areaUpdateCombo
void SupplierManageWindow::areaUpdateCombo(bool select)
{
QSqlTableModel *ptrModel = m_model->relationModel(SupplierManageWindow::idArea);
if(select)
ptrModel->select();
ptrModel->insertRow(0);
ptrModel->setData(ptrModel->index(0, ptrModel->fieldIndex("name")),
trUtf8("-- Seleccione Rubro --"), Qt::EditRole);
cb_area->setModel(ptrModel);
cb_area->setModelColumn(ptrModel->fieldIndex("name"));
cb_area->setCurrentIndex(0);
}
示例3: insertRow
void Browser::insertRow()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
if (!model)
return;
QModelIndex insertIndex = table->currentIndex();
int row = insertIndex.row() == -1 ? 0 : insertIndex.row();
model->insertRow(row);
insertIndex = model->index(row, 0);
table->setCurrentIndex(insertIndex);
table->edit(insertIndex);
}
示例4: insertRow
void FenPrincipale::insertRow()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(tablemesures->model());
if (!model)
return;
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
QModelIndex insertIndex = tablemesures->currentIndex();
int row = insertIndex.row() == -1 ? 0 : insertIndex.row();
model->insertRow(row);
insertIndex = model->index(row, 0);
tablemesures->setCurrentIndex(insertIndex);
tablemesures->edit(insertIndex);
}