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


C++ QSqlQueryModel::record方法代码示例

本文整理汇总了C++中QSqlQueryModel::record方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlQueryModel::record方法的具体用法?C++ QSqlQueryModel::record怎么用?C++ QSqlQueryModel::record使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSqlQueryModel的用法示例。


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

示例1: getDistinctFromDB

QVector<InternalPaymentItem *> ClinicInternalPayment::selectFromDB(QDate startDate, QDate endDate)
{
    QVector<InternalPaymentItem *> result;
    if(myDB::connectDB())
    {
        QString strClumn = "ChinicReceipt";
        QVector<QString> Receipt = getDistinctFromDB(strClumn , strClinicChargeDetails);

        QSqlQueryModel *sqlModel = new QSqlTableModel;
        for(int i=0;i<Receipt.size();i++)
        {
            InternalPaymentItem *item = new InternalPaymentItem;
            item->m_strName = Receipt.at(i);

            QString startTime = startDate.toString("yyyy-MM-dd") + "T00:00:00";
            QString endTime = endDate.toString("yyyy-MM-dd") + "T23:59:59";
            sqlModel->setQuery("Select * from " + strClinicChargeDetails +
                               " where "+ strClumn + "= \'" + item->m_strName +
                               "\' and chargeid in (select id from cliniccharge where time between \'" +
                               startTime +
                               "\' and \'" +
                               endTime + "\')");
            for(int j = 0;j<sqlModel->rowCount();j++)
            {
                int nCount = sqlModel->record(j).value("ChargeItemCount").toInt();
                double nPrice = sqlModel->record(j).value("ChargeItemPrice").toDouble();
                item->m_dDueIncome += nCount*nPrice;
            }
            result.append(item);
        }
    }

    return result;
}
开发者ID:xuebeibei,项目名称:HIS,代码行数:34,代码来源:clinicinternalpayment.cpp

示例2: lastNr

/*!
   qso number sent for last qso in log
 */
int Log::lastNr() const
{
    QSqlQueryModel m;
#if QT_VERSION < 0x050000
    m.setQuery("SELECT * FROM log where valid='true'", db);
#else
    m.setQuery("SELECT * FROM log where valid=1", db);
#endif
    while (m.canFetchMore()) {
        m.fetchMore();
    }
    if (m.rowCount()) {
        QByteArray snt[MAX_EXCH_FIELDS];
        snt[0] = m.record(m.rowCount() - 1).value(SQL_COL_SNT1).toByteArray();
        snt[1] = m.record(m.rowCount() - 1).value(SQL_COL_SNT2).toByteArray();
        snt[2] = m.record(m.rowCount() - 1).value(SQL_COL_SNT3).toByteArray();
        snt[3] = m.record(m.rowCount() - 1).value(SQL_COL_SNT4).toByteArray();
        bool ok = false;
        int  nr = snt[nrField].toInt(&ok, 10);
        if (!ok) nr = 0;
        return(nr);
    } else {
        return(0);
    }
}
开发者ID:n4ogw,项目名称:so2sdr,代码行数:28,代码来源:log.cpp

示例3: CargarDasignar

void Gconsignaciones::CargarDasignar(){
    QSqlQueryModel idunicomodel;
    QString selec="SELECT Id_pro, cantidad, Pconsig FROM Producto where (nombre='"+ui->productocomboBox2->currentText()+"')";
    idunicomodel.setQuery(selec);
    int id_pro=idunicomodel.record(0).value("Id_pro").toInt();
    int cantidad=idunicomodel.record(0).value("cantidad").toInt();
    double precio=idunicomodel.record(0).value("Pconsig").toDouble();
    ui->costo2spinbox->setValue(precio);
    ui->cantidad2->setRange(1, cantidad);
    ui->id2spinbox->setValue(id_pro);
}
开发者ID:jorgenio,项目名称:pandasoft,代码行数:11,代码来源:gconsignaciones.cpp

示例4: onAirportChanged

void SingleWeatherParamWidget::onAirportChanged(QString apCode, QString pName){
    //清空
    QList<int> keyList = editHash.keys();
    for(int key : keyList){
        QList<QLineEdit *> editList = editHash[key];
        for(QLineEdit *edit : editList){
            edit->setText("");
        }
    }

    //赋值
    currentApCode = apCode;
    currentPName = pName;
    weatherParamSetupList.clear();
    QString queryStr = QString("select * from weatherparamsetup where code = '%1' and planename = '%2' order by paramid")
            .arg(currentApCode)
            .arg(currentPName);
    QSqlQueryModel *plainModel = pgDb->queryModel(queryStr);
    int rowCount = plainModel->rowCount();
    for(int i = 0;i < rowCount;i++){
        WeatherParamSetup weatherParamSetup;
        weatherParamSetup.setCode(plainModel->record(i).value(0).toString());
        weatherParamSetup.setPlaneName(plainModel->record(i).value(1).toString());
        weatherParamSetup.setParamid(plainModel->record(i).value(2).toInt());
        weatherParamSetup.setLimits(plainModel->record(i).value(3).toString());
        bool isExist = false;
        for(WeatherParam weatherParam : weatherParamList){
            if(weatherParam.id() == weatherParamSetup.paramid()){
                isExist = true;
                break;
            }
        }
        if(isExist){
            weatherParamSetupList.append(weatherParamSetup);
        }
    }
    delete plainModel;
    for(WeatherParamSetup weatherParamSetup : weatherParamSetupList){
        int key = weatherParamSetup.paramid();
        QString limitJson = weatherParamSetup.limits();
        QList<QString> valueList = this->getDataFromJson(limitJson);
        QList<QLineEdit *> editList = editHash[key];
        int valueCount = valueList.count();
        int editCount = editList.count();
        for(int i = 0;i < editCount;i++){
            QLineEdit *edit = editList[i];
            if(valueCount != editCount){
                edit->setText("");
            }else{
                edit->setText(valueList[i]);
            }
        }
    }
}
开发者ID:skypanda100,项目名称:airportevaluation,代码行数:54,代码来源:weatherparamsetupwidget.cpp

示例5: init_data

void shift_work::init_data()
{
    QString date1 = ui->label_7->text();
    QString date2 = ui->label_8->text();
    QSqlQueryModel model;
    model.setQuery(QString("select count(a.ch_tableno), ifnull(sum(a.int_person), 0)from cey_u_table a , cey_u_checkout_master b where a.ch_payno =b.ch_payno and b.ch_state ='Y' and(b.vch_operID ='%1')and(b.dt_operdate >= '%2' and b.dt_operdate <='%3' )").arg(n_func::gs_operid).arg(date1).arg(date2));
    taishu = model.record(0).value(0).toString();
    renshu = model.record(0).value(1).toString();

    model.clear();
    model.setQuery(QString("Select ifnull(sum(num_cost), 0), ifnull(sum(num_discount), 0), ifnull(sum(num_present), 0), ifnull(sum(num_service), 0), ifnull(sum(num_lowcost), 0), ifnull(sum(num_blotout), 0), ifnull(sum (ifnull( num_free ,0)) , 0 ),ifnull(sum(num_cost), 0 )+ ifnull(sum(num_rate), 0 )- ifnull(sum(num_discount), 0)-ifnull(sum(num_present), 0)+ifnull(sum(num_service), 0)+ ifnull(sum(num_lowcost), 0)-ifnull(sum(num_blotout), 0)-ifnull(sum (ifnull(num_free,0 )) , 0 ),ifnull(sum(num_rate), 0)from cey_u_checkout_master where ch_state ='Y' and(vch_operID ='%1')and(dt_operdate >= '%2' and dt_operdate <= '%3' )").arg(n_func::gs_operid).arg(date1).arg(date2));
    xiaofei = QString().sprintf("%0.2f",model.record(0).value(0).toFloat());
    zhekou = QString().sprintf("%0.2f",model.record(0).value(1).toFloat());
    zengsong = QString().sprintf("%0.2f",model.record(0).value(2).toFloat());
    fuwufei = QString().sprintf("%0.2f",model.record(0).value(3).toFloat());
    dixiao = QString().sprintf("%0.2f",model.record(0).value(4).toFloat());
    moling = QString().sprintf("%0.2f",model.record(0).value(5).toFloat());
    miandan = QString().sprintf("%0.2f",model.record(0).value(6).toFloat());
    yingshou = QString().sprintf("%0.2f",model.record(0).value(7).toFloat());
    shuishou = QString().sprintf("%0.2f",model.record(0).value(8).toFloat());

    //    model.clear();
    //    model.setQuery(QString("Select ifnull(sum(num_deposit), 0) from t_m_deposit where(vch_operID ='%1')and(dt_operdate >= '%2' and dt_operdate <= '%3')").arg(n_func::gs_operid).arg(date1).arg(date2));
    //    kafue = QString().sprintf("%0.2f",model.record(0).value(0).toFloat());//充值金额
    //    qDebug() << model.query().lastQuery();

    //    model.clear();
    //    model.setQuery(QString("Select ifnull(sum(num_realamount), 0) from t_m_deposit where(vch_operID ='%1')and(dt_operdate >= '%2' and dt_operdate <= '%3' )").arg(n_func::gs_operid).arg(date1).arg(date2));
    //    kafue_realamount = QString().sprintf("%0.2f",model.record(0).value(0).toFloat());//充值实收
    //    qDebug() << model.query().lastQuery();
}
开发者ID:ch593030323,项目名称:fastfd,代码行数:31,代码来源:shift_work.cpp

示例6: init_table

void shift_work::init_table()
{
    QString date1 = ui->label_7->text();
    QString date2 = ui->label_8->text();
    QSqlQueryModel model;
    QSettings conf(public_sql::settings_ini_dir_file, QSettings::IniFormat);

    model_top = new QStandardItemModel();
    model_rfb = new QStandardItemModel();
    model_top->setHorizontalHeaderLabels(QStringList()<<tr("收款方式")<<tr("收款次数")<<tr("收款金额")<<tr("面额"));
    model_rfb->setHorizontalHeaderLabels(QStringList()<<tr("会员卡操作方式")<<tr("操作次数")<<tr("金额"));
    ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);ui->tableView->setModel(model_top);
    ui->tableView_2->setEditTriggers(QAbstractItemView::NoEditTriggers);ui->tableView_2->setModel(model_rfb);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->tableView_2->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
    ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    ui->tableView_2->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
    model.setQuery(QString("Select a.ch_paymodeno , count( a.ch_paymodeno), sum( a.num_realamount), sum( a.num_face),IFNULL(c.vch_paymodename,a.ch_paymodeno) , IFNULL(c.ch_faceflag,'N') from cey_u_checkout_detail a , cey_u_checkout_master b ,cey_bt_paymode c where (c.ch_paymodeno =a.ch_paymodeno)and( a.ch_payno =b.ch_payno)and(b.ch_state ='Y') and(b.vch_operID ='%1')and(b.dt_operdate >= '%2' and b.dt_operdate <= '%3')Group by a.ch_paymodeno ,c.vch_paymodename , c.ch_faceflag  having sum( a.num_realamount)> 0 or sum( a.num_payamount)> 0 Order by a.ch_paymodeno ,c.vch_paymodename , c.ch_faceflag").arg(n_func::gs_operid).arg(date1).arg(date2));
    for(int i = 0; i < model.rowCount(); i++)
    {
        int row = model_top->rowCount();
        model_top->setRowCount(row + 1);
        model_top->setItem(row,0,new QStandardItem(model.record(i).value(4).toString()));
        model_top->setItem(row,1,new QStandardItem(model.record(i).value(1).toString()));
        model_top->setItem(row,2,new QStandardItem(QString().sprintf("%0.2f",model.record(i).value(2).toFloat())));
        model_top->setItem(row,3,new QStandardItem(QString().sprintf("%0.2f",model.record(i).value(3).toFloat())));
    }

    model.setQuery(QString("select sum(num_deposit),count(*) from t_m_deposit where ch_deposit_mode='1' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2));
    model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(kafue=model.record(0).value(0).toString()));
    model.setQuery(QString("select sum(num_realamount),count(*) from t_m_deposit where ch_deposit_mode='1' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2));
    model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值实收")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(kafue_realamount=model.record(0).value(0).toString()));
    model.setQuery(QString("select sum(num_deposit),count(*) from t_m_deposit where ch_deposit_mode='8' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2));
    model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("取款")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(card_fetch=model.record(0).value(0).toString()));
    model.setQuery(QString("select sum(num_deposit),count(*) from t_m_deposit where ch_deposit_mode='5' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2));
    model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("退卡")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(card_back=model.record(0).value(0).toString()));

    if(conf.value("w_sys_manage_cloudsync_basedataset/yun_start",false).toBool()){
        w_sys_manage_cloudsync::member_r_f_b_info mrfb=w_sys_manage_cloudsync::get_yun_member_r_f_b(n_func::gs_operid, date1, date2);
        model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值(云)")<< new QStandardItem("")<< new QStandardItem(card_recharge_yun=mrfb.rechargeAmount));
        model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值实收(云)")<< new QStandardItem("")<< new QStandardItem(card_recharge_realamount_yun=mrfb.realRechargeAmount));
        model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("取款(云)")<< new QStandardItem("")<< new QStandardItem(card_fetch_yun=mrfb.withdrawalAmount));
        model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("退卡(云)")<< new QStandardItem("")<< new QStandardItem(card_back_yun=mrfb.backCardAmount));
    }
}
开发者ID:ch593030323,项目名称:fastfd,代码行数:48,代码来源:shift_work.cpp

示例7: checkExists

bool DataBank::checkExists(unsigned int i)
{
    bool bit = false;
    bool ok = false;

    if(!database.open()){
        qDebug()<<"database database is error";
    }else{
        qDebug()<<"database database is ok";
    }

    /*查询数据库中的所有表名*/
    QSqlQueryModel model;
    model.setQuery("select name from sqlite_master where type='table'",database);

    for(int j = 0; j < model.rowCount(); ++j){
        QString name = model.record(j).value("name").toString();
        if((unsigned int)name.mid(5,2).toInt(&ok ,10) == i){
            bit = true;
        }
    }

    database.close();
    return bit;
}
开发者ID:taiyuankejizhu,项目名称:SparkZNC,代码行数:25,代码来源:databank.cpp

示例8: on_pBtn_remove_Event_clicked

//Eventname, der aktiviert wurde, mit remove-pBtn löschen
//inklusive der an diesem Event beteiligten Teilnehmern.
void MainWindow::on_pBtn_remove_Event_clicked()
{

    QSqlQueryModel *model = (QSqlQueryModel*)ui->listView->model();
    QSqlRecord record = model->record(ui->listView->currentIndex().row());
    QSqlField field_ID = record.field("ID");
    QSqlField field_EventName = record.field("EventName");

    QMessageBox msg;
    msg.setText("Achtung es werden auch alle Teilnehmer, \n die zu diesem Event gehören, gelöscht! \n\n Soll das Event: \n \" " +field_EventName.value().toString()+ "\"\n unwiederruflich gelöscht werden?");
    msg.setWindowTitle("Eintrag entfernen");
    msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msg.setIcon(QMessageBox::Critical);
    msg.setButtonText(QMessageBox::Yes, "Ja");
    msg.setButtonText(QMessageBox::No, "Nein");
    msg.setDefaultButton(QMessageBox::No);

    if (msg.exec() == QMessageBox::Yes)
    {
        DBank a;
        QString ID = field_ID.value().toString();
        a.removeEvent(ID);
        qDebug()<< field_ID.value().toString();
        updateListView();
    }
    else
    {
        qDebug()<<"EventName-Eintrag wird nicht gelöscht.";
    }
}
开发者ID:AngelaSteiner,项目名称:sbd-ammersee,代码行数:32,代码来源:mainwindow.cpp

示例9: data

/*! Reimplemented to export the Qt::DecorationRole. */
QVariant MetaListViewPart::ProxyModel::data(const QModelIndex & index, int role) const
{
    if ( index.isValid() and (role == Qt::DecorationRole or role == Qt::DisplayRole) ) {
        QSqlQueryModel *m = qobject_cast<QSqlQueryModel*>(sourceModel());
        Q_ASSERT(m);
        QModelIndex sourceIndex = mapToSource(index);
        Q_ASSERT(sourceIndex.isValid());
        
        switch(role) {
            case Qt::DecorationRole:
            {
                QString icon = m->record(sourceIndex.row()).value("icon").toString();
                return !icon.isEmpty() ? QIcon(icon) : KIcon("wine");
                break;
            }
            case Qt::DisplayRole:
            {
                return ( sourceIndex.row() == m_metaListViewPart->m_defaultRow )
                            ? sourceIndex.data(role).toString().prepend("* ") : sourceIndex.data(role);
                break;
            }
            default:
                Q_ASSERT(false);
        }
    }

    return QSortFilterProxyModel::data(index, role);
}
开发者ID:gkiagia,项目名称:qtwine,代码行数:29,代码来源:metalistviewpart.cpp

示例10: cargarDatosTarifa

void FrmTarifas::cargarDatosTarifa(QModelIndex indice)
{
    QSqlQueryModel* modelo = (QSqlQueryModel*)ui->listaTarifa->model();
    QString tarifa = modelo->record(indice.row()).value("descripcion").toString();
    QSqlQuery qTarifa(Configuracion_global->groupDB);
    qTarifa.prepare("select * from codigotarifa where descripcion ='"+tarifa+"'");

    if(qTarifa.exec()){
        qTarifa.next();

        ui->txtCodTarifa->setText(qTarifa.record().field("codigo_tarifa").value().toString());
        ui->txtDescTarifa->setText(qTarifa.record().field("descripcion").value().toString());
        ui->txtPais->setText(Configuracion_global->Devolver_pais(qTarifa.record().field("id_pais").value().toInt()));
        ui->txtMoneda->setText(Configuracion_global->Devolver_moneda(qTarifa.record().field("id_monedas").value().toInt()));
        this->id_tarifa = qTarifa.record().field("id").value().toInt();
        this->id_pais = qTarifa.record().field("id_pais").value().toInt();
        this->id_moneda = qTarifa.record().field("id_monedas").value().toInt();
        this->cod_divisa = Configuracion_global->Devolver_codDivisa(this->id_moneda);
        this->codigoTarifa = qTarifa.record().field("codigo_tarifa").value().toString();
        this->margen = ui->spinMargen->value();
        this->pvpDivisa = qTarifa.record().field("pvp").value().toDouble();
        this->margen_min = ui->spinmargen_minimo->value();
        if (Configuracion_global->divisa_local != ui->txtMoneda->text())
            Configuracion_global->getCambio(Configuracion_global->cod_divisa_local,this->cod_divisa);
        else
            asignarcambiodivisa(1);
    }
    calcular_precio(ui->spinMargen->value());

}
开发者ID:arcnexus,项目名称:RedFoX,代码行数:30,代码来源:frmtarifas.cpp

示例11: Principal

void pandasoft::Principal()
{
    ui->error->hide();
    ui->error0->hide();
    ui->usuario->setStyleSheet("background-color: none;");
    ui->clave->setStyleSheet("background-color: none;");

    if(ui->usuario->text().isEmpty()||ui->clave->text().isEmpty()){
        if(ui->usuario->text().isEmpty()){
            ui->error->show();
            ui->usuario->setStyleSheet("background-color: red;");
        }
        if(ui->clave->text().isEmpty()){
            ui->error->show();
            ui->clave->setStyleSheet("background-color: red;");
        }
    }
    else {
    QSqlQueryModel model;
    QString consulta="select Nombre, Ap, Am, Rol from Usuario where (Nombre='"+ui->usuario->text()+"' and Contrasena='"+ui->clave->text()+"' )";
    model.setQuery(consulta);

    if(model.record(0).value("Rol").toString()==""){
    ui->error0->show();
    }else{
    QString rol = model.record(0).value("Rol").toString();
    rolusu=rol;
    QString usuario = model.record(0).value("Nombre").toString()+" "+model.record(0).value("Ap").toString()+" "+model.record(0).value("Am").toString();
    this->setWindowTitle("Principal");
    ui->pandasoftstackedWidget->setCurrentIndex(1);
    ui->menubar->show();
    if(rolusu=="1"){
    ui->menuMenu_Gerente->setEnabled(false);
    ui->cabecera->setText("Bienvenido Usuario: "+usuario+"           Rol : Jefe de Almacen");

    }else{
        ui->cabecera->setText("Bienvenido Usuario: "+usuario+"            Rol : Gerente");
    }
    }
    ui->alertalista->setEnabled(false);
    QString alerta="select Nombre from Producto where Cantidad<Lim_stock";
    model.setQuery(alerta);
    ui->alertalista->setText(model.record(0).value("Nombre").toString());

}
}
开发者ID:jorgenio,项目名称:pandasoft,代码行数:46,代码来源:pandasoft.cpp

示例12: RestoreConfig_color

void LazyWord::RestoreConfig_color()			//Get the configuration of color from the database
{
	QSqlQueryModel GetTheLastconfig;
	GetTheLastconfig.setQuery("select * from LastConfig;");
	
    QSqlRecord Lastconfig_Record = GetTheLastconfig.record(0);
    colorselect = Lastconfig_Record.value("Color").toString();
}
开发者ID:san0xff,项目名称:lazyword,代码行数:8,代码来源:LazyWord.cpp

示例13: initData

void MultiWeatherParamWidget::initData(){
    //初始化DB
    pgDb = new PgDataBase;
    //多要素
    QString queryStr = QString("select * from weatherparam where choose_type = 1 and limit_type <> 0 order by id");
    QSqlQueryModel *plainModel = pgDb->queryModel(queryStr);
    int rowCount = plainModel->rowCount();
    for(int i = 0;i < rowCount;i++){
        WeatherParam weatherParam;
        weatherParam.setId(plainModel->record(i).value(0).toInt());
        weatherParam.setName(plainModel->record(i).value(1).toString());
        weatherParam.setChoose_type(plainModel->record(i).value(2).toInt());
        weatherParam.setLimit_type(plainModel->record(i).value(3).toInt());
        weatherParamList.append(weatherParam);
    }
    delete plainModel;
}
开发者ID:skypanda100,项目名称:airportevaluation,代码行数:17,代码来源:weatherparamsetupwidget.cpp

示例14: tableMake

void DataBank::tableMake(LONG64 ideep,UNINT32 imaterial,UNINT32 iacreage,UNINT32 ieffect,UNINT32 iry ,UNINT32 iovc,UNINT32 ishape)
{
    bool ok = false;
    QString sql = QString("select * from '%1'");
    QString name = "";
    if(imaterial == 0){
        name = "cust";
    }else{
        name = "crst";
    }
    name.append(QString::number(ishape,10));
    sql.arg(name);

    if(!database.open()){
        qDebug()<<"spark database is error";
    }else{
        qDebug()<<"spark database is ok";
    }

    QSqlQueryModel model;
    model.setQuery(sql,database);

    for(int i = 0; i < model.rowCount(); ++i){
        int id = model.record(i).value("h_area").toInt();
        QString name = model.record(i).value("no").toString();
        qDebug() << id << name;
    }

/*
    QSqlQuery query(database);
    query.prepare("select * from cust0 where h_area > :value1 and l_area < :value2 and cnf = 0");
    query.bindValue(":value1" ,2);
    query.bindValue(":value2" ,2);
    b = query.exec();
    if(!b){
        qDebug()<<"table is error";
    }else{
        qDebug()<<"table is ok";
        while(query.next()){
            qDebug()<<query.value(S_OFS).toString()<<query.value(PP).toString();
        }
    }
*/

    database.close();
}
开发者ID:taiyuankejizhu,项目名称:SparkZNC,代码行数:46,代码来源:databank.cpp

示例15: SetDb

void PringKvitok::SetDb(db *mdb)
{
    myDB = mdb;
     ui->comboBox_groups->addItem("Выбрать все", "s_all");
    ui->comboBox_groups->addItem("Снять все", "d_all");
    QSqlQueryModel *groups = myDB->Query("SELECT * FROM groups WHERE id > 2");
    for(int i = 0; i < groups->rowCount(); i++){
         ui->comboBox_groups->addItem(groups->record(i).value("name").toString(), groups->record(i).value("id").toString());
    }

    childsCheckBox_map.clear();
   QString sql = "SELECT t0.id, t0.group_id, t0.fio,  t1.name AS group_name, t0.ls FROM childs t0";
    sql += " LEFT OUTER  JOIN groups  t1 ON t0.group_id = t1.id";
    QSqlQueryModel *childs = myDB->Query(sql);
    for(int i = 0; i < childs->rowCount(); i++){
          QString childs_id = childs->record(i).value("id").toString();
          ui->tW->insertRow(ui->tW->rowCount());
          ui->tW->setItem(ui->tW->rowCount() - 1, 1,new QTableWidgetItem(childs->record(i).value("fio").toString()));
          ui->tW->setItem(ui->tW->rowCount() - 1, 2,new QTableWidgetItem(childs->record(i).value("group_name").toString()));
          ui->tW->setItem(ui->tW->rowCount() - 1, 3,new QTableWidgetItem(childs_id));
          ui->tW->setItem(ui->tW->rowCount() - 1, 4,new QTableWidgetItem(childs->record(i).value("group_id").toString()));
          ui->tW->setItem(ui->tW->rowCount() - 1, 5,new QTableWidgetItem(childs->record(i).value("ls").toString()));
          QCheckBox *cb = new QCheckBox();
          cb->setText(childs_id);
          connect(cb , SIGNAL( toggled(bool) ), this, SLOT( on_childs_toggled(bool)) );
          childsCheckBox_map[childs_id] = cb;
          ui->tW->setCellWidget(ui->tW->rowCount() - 1, 0, cb);

     }
    delete groups;
    delete childs;

}
开发者ID:haltxz,项目名称:ds,代码行数:33,代码来源:pringkvitok.cpp


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