当前位置: 首页>>代码示例>>C++>>正文


C++ QSqlTableModel::removeRow方法代码示例

本文整理汇总了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();
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:15,代码来源:browser.cpp

示例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));
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:15,代码来源:mainwindow.cpp

示例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());

             }
}
开发者ID:sepiropht,项目名称:caltopo,代码行数:16,代码来源:form.cpp

示例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);
       }
开发者ID:sepiropht,项目名称:caltopo,代码行数:18,代码来源:fenprincipale.cpp

示例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();




         }
       }
开发者ID:sepiropht,项目名称:caltopo,代码行数:22,代码来源:fenprincipale.cpp

示例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
    }
开发者ID:zzzzzsh,项目名称:201,代码行数:39,代码来源:studentdialog.cpp

示例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);
    }
}
开发者ID:FromHJ,项目名称:my3Q,代码行数:23,代码来源:loginframe.cpp

示例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");
        }
    }
}
开发者ID:kopolzin,项目名称:bioimages-collection-manager,代码行数:66,代码来源:tableeditor.cpp


注:本文中的QSqlTableModel::removeRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。