• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QSqlRecord函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QSqlRecord函数的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRecord函数的具体用法?C++ QSqlRecord怎么用?C++ QSqlRecord使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QSqlRecord函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: removeRow

/*!
    Deletes the given \a row from the currently active database table.

    This is a low-level method that operates directly on the database
    and should not be called directly. Use removeRow() or removeRows()
    to delete values. The model will decide depending on its edit strategy
    when to modify the database.

    Returns true if the row was deleted; otherwise returns false.

    \sa removeRow(), removeRows()
*/
bool QSqlTableModel::deleteRowFromTable(int row)
{
    Q_D(QSqlTableModel);
    emit beforeDelete(row);

    const QSqlRecord whereValues = d->strategy == OnManualSubmit ? d->cache[row].primaryValues : d->primaryValues(row);
    bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);
    QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement,
                                                d->tableName,
                                                QSqlRecord(),
                                                prepStatement);
    QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,
                                                 d->tableName,
                                                 whereValues,
                                                 prepStatement);

    if (stmt.isEmpty() || where.isEmpty()) {
        d->error = QSqlError(QLatin1String("Unable to delete row"), QString(),
                             QSqlError::StatementError);
        return false;
    }
    stmt.append(QLatin1Char(' ')).append(where);

    return d->exec(stmt, prepStatement, QSqlRecord() /* no new values */, whereValues);
}
开发者ID:phen89,项目名称:rtqt,代码行数:37,代码来源:qsqltablemodel.cpp


示例2: QSqlRecord

QSqlRecord XSqlTableModelProto::record(int row) const
{
  XSqlTableModel *item = qscriptvalue_cast<XSqlTableModel*>(thisObject());
  if (item)
    return item->record(row);
  return QSqlRecord();
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:7,代码来源:xsqltablemodelproto.cpp


示例3: removeRow

/*!
    Deletes the given \a row from the currently active database table.

    This is a low-level method that operates directly on the database
    and should not be called directly. Use removeRow() or removeRows()
    to delete values. The model will decide depending on its edit strategy
    when to modify the database.

    Returns true if the row was deleted; otherwise returns false.

    \sa removeRow(), removeRows()
*/
bool QSqlTableModel::deleteRowFromTable(int row)
{
    Q_D(QSqlTableModel);
    emit beforeDelete(row);

    QSqlRecord rec = d->primaryValues(row);
    bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries);
    QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement,
                                                d->tableName,
                                                QSqlRecord(),
                                                prepStatement);
    QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement,
                                                 d->tableName,
                                                 rec,
                                                 prepStatement);

    if (stmt.isEmpty() || where.isEmpty()) {
        d->error = QSqlError(QLatin1String("Unable to delete row"), QString(),
                             QSqlError::StatementError);
        return false;
    }
    stmt.append(QLatin1Char(' ')).append(where);

    return d->exec(stmt, prepStatement, rec);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:37,代码来源:qsqltablemodel.cpp


示例4: QSqlRecord

QSqlRecord XSqlQueryProto::record() const
{
  XSqlQuery *item = qscriptvalue_cast<XSqlQuery*>(thisObject());
  if (item)
    return item->record();
  return QSqlRecord();
}
开发者ID:xtuple,项目名称:qt-client,代码行数:7,代码来源:xsqlqueryproto.cpp


示例5: agrpAdd

void FormLibraryEditor::agrpAdd()
{
	if (modelAgeGroups->insertRecord(-1, QSqlRecord())) {
		ui->tableViewAgeGroups->update();
		ui->actionAgeGroupCommit->setEnabled(true);
	}
}
开发者ID:pitikov,项目名称:cwall.qt4,代码行数:7,代码来源:formlibraryeditor.cpp


示例6: QSqlRecord

QSqlRecord SqliteDriver::record2(const QString &tblname) const
{
  if (!isOpen() || !dataBase_)
    return QSqlRecord();

  return recordInfo(tblname).toRecord();
}
开发者ID:gestiweb,项目名称:eneboo,代码行数:7,代码来源:qsqlite.cpp


示例7: QSqlRecord

QVariant EventColorQSqlQueryModel::data(const QModelIndex &index, int role) const
{
    QVariant value = QSqlQueryModel::data(index, role);

    if (role == Qt::BackgroundColorRole)
    {
        int level=	QSqlRecord (record(index.row())).value(4).toInt();
        switch(level)
        {
        case 1 : return qVariantFromValue(QColor(0xff,0xca,0x00));
        case 2 : return qVariantFromValue(QColor(Qt::red));
        case 3 : return qVariantFromValue(QColor(Qt::gray));
        case 4 : return qVariantFromValue(QColor(Qt::green));
        }
    }
    if(role==Qt::DisplayRole )
    {

        if (index.column() == 4)
        {
            switch(value.toInt())
            {
            case 0 : return qVariantFromValue(tr("Program"));
            case 1 : return qVariantFromValue(tr("Level I"));
            case 2 : return qVariantFromValue(tr("Level II"));
            case 3 : return qVariantFromValue(tr("Fault"));
            case 4 : return qVariantFromValue(tr("Correct"));
            }
        }

    }
    return value;
}
开发者ID:mishapk,项目名称:pcn,代码行数:33,代码来源:eventcolorqsqlquerymodel.cpp


示例8: query

QSqlRecord GenericDAO::getRecord(const QSqlDatabase& db, const QString& where, const QVariantList& bindValues) const
{
    if (db.isOpen())
    {
        QSqlQuery query(db);
        query.setForwardOnly(true);
        QString sql = QString("SELECT * FROM %1 WHERE %2").arg(m_table).arg(where);
        query.prepare(sql);
        int n = bindValues.size();
        for (int i = 0; i < n; i++)
        {
            query.bindValue(i, bindValues[i]);
        }

        if (query.exec())
        {
            if (query.next())
            {
                return query.record();
            }
        }
        else
            DatabaseException(query).displayMessage();
    }

    return QSqlRecord();
}
开发者ID:koboveb,项目名称:SVID.TERMINAL,代码行数:27,代码来源:genericdao.cpp


示例9: QSqlRecord

QSqlRecord QSQLiteDriver::record(const QString &tblname) const
{
    if (!isOpen())
        return QSqlRecord();

    return recordInfo(tblname).toRecord();
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:7,代码来源:qsql_sqlite.cpp


示例10: QSqlRecord

QSqlRecord FormFirewallRules::getFirewallRulesetFromShortName(QString shortName)
{
    QSqlRecord result = QSqlRecord();
    QSqlQuery qry;
    QVariant sn(shortName);

    qry.prepare(" select id, name, shortname, rules "
                " from ruleset "
                " where shortname = :shortname");
    qry.bindValue(":shortname", sn);

    if (qry.exec())
    {
        if (qry.first())
        {
            result = qry.record();
        }
        else
        {
            qDebug("FormFirewallRules::getFirewallRulesetFromShortName Can't move to first row [%s]",
                   qry.lastError().text().toAscii().data());
        }

    }
    else
    {
        qDebug("FormFirewallRules::getFirewallRulesetFromShortName query failed [%s]",
               qry.lastError().text().toAscii().data());
    }

    return result;
}
开发者ID:tailored,项目名称:qiptables,代码行数:32,代码来源:formfirewallrules.cpp


示例11: QSqlRecord

/* ********************************************************************* */
QSqlRecord BarlowsDataMapper::currentRecord()
{ 
	if (lastRowNumberSelected == -1) {
		return QSqlRecord();
	} else {
		return tableModel->record(lastRowNumberSelected);
	}
}
开发者ID:EvilTosha,项目名称:Stellarium-GSoC12,代码行数:9,代码来源:BarlowsDataMapper.cpp


示例12: QSqlRecord

QSqlRecord TargetsDialog::currentRecord()
{ 
	if (lastRowNumberSelected == -1) {
		return QSqlRecord();
	} else {
		return tableModel->record(lastRowNumberSelected);
	}
}
开发者ID:NGCyang,项目名称:stellarium,代码行数:8,代码来源:TargetsDialog.cpp


示例13: QSqlRecord

void FormLibraryEditor::teamAdd()
{
	int row = modelTeams->rowCount();
	modelTeams->insertRecord(-1, QSqlRecord());
	ui->tableViewTeams->setCurrentIndex(modelTeams->index(row, modelTeams->fieldIndex("label")));
	ui->actionTeamCommit->setEnabled(true);
	ui->actionDifficultyDelete->setDisabled(true);
}
开发者ID:pitikov,项目名称:cwall.qt4,代码行数:8,代码来源:formlibraryeditor.cpp


示例14: isForwardOnly

/*!
    Resets the model and sets the data provider to be the given \a
    query. Note that the query must be active and must not be
    isForwardOnly().

    lastError() can be used to retrieve verbose information if there
    was an error setting the query.

    \sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError()
*/
void QSqlQueryModel::setQuery(const QSqlQuery &query)
{
    Q_D(QSqlQueryModel);
    QSqlRecord newRec = query.record();
    bool columnsChanged = (newRec != d->rec);
    bool hasQuerySize = query.driver()->hasFeature(QSqlDriver::QuerySize);
    bool hasNewData = (newRec != QSqlRecord()) || !query.lastError().isValid();

    if (d->colOffsets.size() != newRec.count() || columnsChanged)
        d->initColOffsets(newRec.count());

    bool mustClearModel = d->bottom.isValid();
    if (mustClearModel) {
        d->atEnd = true;
        beginRemoveRows(QModelIndex(), 0, qMax(d->bottom.row(), 0));
        d->bottom = QModelIndex();
    }

    d->error = QSqlError();
    d->query = query;
    d->rec = newRec;

    if (mustClearModel)
        endRemoveRows();

    d->atEnd = false;

    if (columnsChanged && hasNewData)
        reset();

    if (!query.isActive() || query.isForwardOnly()) {
        d->atEnd = true;
        d->bottom = QModelIndex();
        if (query.isForwardOnly())
            d->error = QSqlError(QLatin1String("Forward-only queries "
                                               "cannot be used in a data model"),
                                 QString(), QSqlError::ConnectionError);
        else
            d->error = query.lastError();
        return;
    }
    QModelIndex newBottom;
    if (hasQuerySize && d->query.size() > 0) {
        newBottom = createIndex(d->query.size() - 1, d->rec.count() - 1);
        beginInsertRows(QModelIndex(), 0, qMax(0, newBottom.row()));
        d->bottom = createIndex(d->query.size() - 1, columnsChanged ? 0 : d->rec.count() - 1);
        d->atEnd = true;
        endInsertRows();
    } else {
        newBottom = createIndex(-1, d->rec.count() - 1);
    }
    d->bottom = newBottom;

    queryChange();

    // fetchMore does the rowsInserted stuff for incremental models
    fetchMore();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:68,代码来源:qsqlquerymodel.cpp


示例15: entryFromIndex

QSqlRecord LibraryModel::record(const QModelIndex &index)
{
    LibraryEntry * item = entryFromIndex(index);
    if(item->isDirNode()) {
        return QSqlRecord();
    } else {
        return item->record();
    }
}
开发者ID:alorence,项目名称:tym,代码行数:9,代码来源:librarymodel.cpp


示例16: QSqlRecord

QSqlRecord QSymSQLResult::record() const
{
    if (!isActive() || !isSelect())
        return QSqlRecord();
    
    QSqlRecord res;
    d->initColumns(res);
            
    return res;
}
开发者ID:maxxant,项目名称:qt,代码行数:10,代码来源:qsql_symsql.cpp


示例17: objectIterator

void TargetsDialog::createTargetFromSelection()
{
	if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) {
		QList<StelObjectP> selectedObjects = StelApp::getInstance().getStelObjectMgr().getSelectedObject();
		QListIterator<StelObjectP> objectIterator(selectedObjects);
		StelCore* core = StelApp::getInstance().getCore();
		while (objectIterator.hasNext()) {
			StelObjectP stelObject = objectIterator.next();
			QString type = stelObject->getType();
			QString englishName = stelObject->getEnglishName();
			if (englishName == "") {
				englishName = "No Name";
			}
			float magnatude = stelObject->getVMagnitude(core);
			double angularSize = stelObject->getAngularSize(core);
			
			Vec3d pos;
			double ra, dec;
			// ra/dec in J2000
			pos = stelObject->getJ2000EquatorialPos(core);
			StelUtils::rectToSphe(&ra, &dec, pos);
			
		    QSqlField field1("name", QVariant::String);
			QSqlField field2("right_ascension", QVariant::Double);
			QSqlField field3("declination", QVariant::Double);
			QSqlField field4("target_type_id", QVariant::Int);
			QSqlField field5("magnitude", QVariant::Double);
			QSqlField field6("size", QVariant::Double);
			field1.setValue(QVariant(englishName));
			field2.setValue(QVariant(ra));
			field3.setValue(QVariant(dec));
			field4.setValue(QVariant(1));
			field5.setValue(QVariant(magnatude));
			field6.setValue(QVariant(angularSize));
			QSqlRecord newRecord = QSqlRecord();
			newRecord.append(field1);
			newRecord.append(field2);
			newRecord.append(field3);
			newRecord.append(field4);
			newRecord.append(field5);
			newRecord.append(field6);
			
			if (tableModel->insertRecord(-1, newRecord)) {
				ui->targetsListView->setCurrentIndex(tableModel->index(tableModel->rowCount() - 1, 1));
			} else {
				qWarning() << "LogBook: could not insert new target.  The error is: " << tableModel->lastError();
			}
		}
	} else {
		qDebug() << "====> Nothing selected.";
	}
}	
开发者ID:NGCyang,项目名称:stellarium,代码行数:52,代码来源:TargetsDialog.cpp


示例18: QSqlRecord

QSqlRecord QSQLite2Driver::record(const QString &tbl) const
{
    if (!isOpen())
        return QSqlRecord();
    QString table = tbl;
    if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
        table = stripDelimiters(table, QSqlDriver::TableName);

    QSqlQuery q(createResult());
    q.setForwardOnly(true);
    q.exec(QLatin1String("SELECT * FROM ") + tbl + QLatin1String(" LIMIT 1"));
    return q.record();
}
开发者ID:RS102839,项目名称:qt,代码行数:13,代码来源:qsql_sqlite2.cpp


示例19: QSqlRecord

QSqlRecord QSpatiaLiteDriver::record(const QString &tbl) const
{
    if (!isOpen())
        return QSqlRecord();

    QString table = tbl;
    if (isIdentifierEscaped(table, QSqlDriver::TableName))
        table = stripDelimiters(table, QSqlDriver::TableName);

    QSqlQuery q(createResult());
    q.setForwardOnly(true);
    return qGetTableInfo(q, table);
}
开发者ID:Br1ndavoine,项目名称:QGIS,代码行数:13,代码来源:qsql_spatialite.cpp


示例20: QSqlRecord

QSqlRecord SQLiteDriver::record(const QString &tbl) const
{
    if (!isOpen())
        return QSqlRecord();

    QString table = tbl;
#if (QT_VERSION >= 0x040500)
    if (isIdentifierEscaped(table, QSqlDriver::TableName))
        table = stripDelimiters(table, QSqlDriver::TableName);
#endif

    QSqlQuery q(createResult());
    q.setForwardOnly(true);
    return qGetTableInfo(q, table);
}
开发者ID:Helgion,项目名称:quiterss,代码行数:15,代码来源:sqlitedriver.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QSslCertificate函数代码示例发布时间:2022-05-30
下一篇:
C++ QSqlQuery函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap