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


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

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


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

示例1: refreshTables

//! Populates the checked in and not checked in item tables.
void wndInventoryCheck::refreshTables( void )
{
    QSqlQuery checkedQuery;
    checkedQuery.prepare( "SELECT iid,name FROM inventorycheck WHERE checked=1" );
    _pDB->query( checkedQuery );
    QSqlQueryModel *checkmodel = new QSqlQueryModel;
    checkmodel->setQuery(checkedQuery);

    // Set header values
    checkmodel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
    checkmodel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );

    // Set options for the QTableView
    _pUI->tblCheckedIn->setModel( checkmodel );
    _pUI->tblCheckedIn->verticalHeader()->hide();
    _pUI->tblCheckedIn->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
    _pUI->tblCheckedIn->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );

    QSqlQuery ncheckedQuery;
    ncheckedQuery.prepare( "SELECT iid,name FROM inventorycheck WHERE checked=0" );
    _pDB->query( ncheckedQuery );
    QSqlQueryModel *ncheckmodel = new QSqlQueryModel;
    ncheckmodel->setQuery( ncheckedQuery );

    // Set header values
    ncheckmodel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
    ncheckmodel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );

    // Set options for the QTableView
    _pUI->tblNotCheckedIn->setModel( ncheckmodel );
    _pUI->tblNotCheckedIn->verticalHeader()->hide();
    _pUI->tblNotCheckedIn->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
    _pUI->tblNotCheckedIn->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );
}
开发者ID:JDougherty,项目名称:Fire-Department-Management-System,代码行数:35,代码来源:wndinventorycheck.cpp

示例2: setup

void UserManagement::setup()
{
    {
    Database conn;
    QSqlQueryModel * model = new QSqlQueryModel();

    conn.connOpen("Employee");
    QSqlQuery * qry = new QSqlQuery(conn.mydb);

    qry->prepare("SELECT Name, ID from Employees");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView_Users->setModel(model);
    ui->tableView_Users->setColumnWidth(0, 340);
    ui->tableView_Users->horizontalHeader()->setStretchLastSection(true);
    conn.connClose();
    }

    {
    Database conn;
    QSqlQueryModel * model = new QSqlQueryModel();

    conn.connOpen("Employee");
    QSqlQuery * qry = new QSqlQuery(conn.mydb);

    qry->prepare("SELECT Name, ID from Employees WHERE ONCLOCK = '1'");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView_clock->setModel(model);
    ui->tableView_clock->horizontalHeader()->setStretchLastSection(true);
    conn.connClose();
    }


}
开发者ID:anava014,项目名称:AvisionR---Windows-GUI-Application,代码行数:35,代码来源:usermanagement.cpp

示例3: 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

示例4: 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

示例5: on_lineEdit_cursorPositionChanged

void Search::on_lineEdit_cursorPositionChanged(int arg1, int arg2)
{
    QString name=ui->lineEdit->text();
    if(name.isEmpty())
    {
        QSqlQueryModel *model = new QSqlQueryModel;
            model->setQuery("SELECT firstname, lastname, class, roll_no,STATUS FROM  student where firstname like '"+name+"%'");
            model->setHeaderData(0, Qt::Horizontal, tr("Firstname"));
            model->setHeaderData(1, Qt::Horizontal, tr("Lastname"));
            model->setHeaderData(2,Qt::Horizontal,tr("Class"));
            model->setHeaderData(3,Qt::Horizontal,tr("Roll"));
             model->setHeaderData(4,Qt::Horizontal,tr("Status"));
             ui->tableView->setModel(model);
    }
    else
    {
    QSqlQueryModel *model = new QSqlQueryModel;
        model->setQuery("SELECT firstname, lastname, class, roll_no,STATUS FROM  student where firstname like '"+name+"%'");
        model->setHeaderData(0, Qt::Horizontal, tr("Firstname"));
        model->setHeaderData(1, Qt::Horizontal, tr("Lastname"));
        model->setHeaderData(2,Qt::Horizontal,tr("Class"));
        model->setHeaderData(3,Qt::Horizontal,tr("Roll"));
         model->setHeaderData(4,Qt::Horizontal,tr("Status"));
         ui->tableView->setModel(model);
    }

}
开发者ID:sailendraw,项目名称:MontesorryManagementSystem,代码行数:27,代码来源:search.cpp

示例6: on_btmBuscar_clicked

void mantenimientoTitulo::on_btmBuscar_clicked()
{
    if(m_ui->btmTitulo->isChecked()) {

        QSqlQueryModel *model = new QSqlQueryModel(m_ui->titulos);
        model->setQuery("SELECT tituloObra, isbn FROM titulo WHERE tituloObra LIKE '%"+m_ui->busqueda->text()+"%';", QSqlDatabase::database("sibcues"));
        if (model->lastError().isValid())
            qDebug() << model->lastError();

        model->setHeaderData(0, Qt::Horizontal, QObject::tr("Titulo Material Bibliografico"));
        model->setHeaderData(1, Qt::Horizontal, QObject::tr("ISBN"));
        m_ui->titulos->setModel(model);
        connect(m_ui->titulos->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_titulos_activated(QModelIndex)));
        m_ui->labelTitulo->setText("Titulos: "+QString::number(model->rowCount())+" resultados.");
    }
    else {

        QSqlQueryModel *model = new QSqlQueryModel(m_ui->titulos);
        model->setQuery("SELECT titulo.tituloObra, titulo.isbn FROM obrade left join titulo on titulo.idTitulo=obrade.idTitulo left join autor on obrade.idAutor=autor.idAutor WHERE autor.nombreAutor LIKE '%"+m_ui->busqueda->text()+"%';", QSqlDatabase::database("sibcues"));

        if (model->lastError().isValid())
            qDebug() << model->lastError();

        model->setHeaderData(0, Qt::Horizontal, QObject::tr("Titulo Material Bibliografico"));
        model->setHeaderData(1, Qt::Horizontal, QObject::tr("ISBN"));
        m_ui->titulos->setModel(model);
        connect(m_ui->titulos->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_titulos_activated(QModelIndex)));
        m_ui->labelTitulo->setText("Titulos: "+QString::number(model->rowCount())+" resultados.");
    }
}
开发者ID:bagonzalez,项目名称:SI-BCUES,代码行数:30,代码来源:mantenimientotitulo.cpp

示例7: setup

void UtilitiesView::setup(int raceTrack){
    //Caricamento tabella tempi
    QSqlQuery q(MainWindow::database);
    q.prepare("SELECT COUNT(*) FROM GPSCoord WHERE CodCircuito = :id");
    q.bindValue(":id",raceTrack);
    q.exec();
    q.next();

    QStringList header;
    header<<"Trascorso"<<"Giro"<<"Gap";
    for(int i=0; i<q.value(0).toInt(); i++){
        header<<QString("Inter. %1").arg(i+1);
    }
    ui->timeTable->setColumnCount(header.count());
    ui->timeTable->setHorizontalHeaderLabels(header);

    GPSSettings settings;
    timeChannel = settings.getSpecialChannel(TIME_CHANNEL);
    lapChannel = settings.getSpecialChannel(LAP_CHANNEL);
    waypointChannel = settings.getSpecialChannel(WAYPOINT_CHANNEL);

    //Caricamento tabella statistiche
    QSqlQueryModel *columnModel = new QSqlQueryModel;
    columnModel->setQuery("SELECT CanID, Nome FROM Canale "
                          "WHERE (CodTipoDato=1 OR CodTipoDato=2) AND (CodTipoIO=1 OR CodTipoIO=3)",
                          MainWindow::database
                          );
    ui->channelList->setModel(columnModel);
    ui->channelList->setModelColumn(1);

    //Caricamento invio msg CAN
    QSqlQueryModel *outputModel = new QSqlQueryModel;
    outputModel->setQuery("SELECT CanID, Nome FROM Canale WHERE (CodTipoIO=2 OR CodTipoIO=3)",
                          MainWindow::database
                          );
    ui->outChannelCombo->setModel(outputModel);
    ui->outChannelCombo->setModelColumn(1);

    statsUpdate->start();

    //Caricamento chiamata team
    //Member::lastCallID = 0;
    QListWidgetItem *item;
    q.exec("SELECT Cognome, Nome, Ruolo,Tel FROM Team ORDER BY Ruolo,Cognome,Nome");
    ui->teamList->clear();
    teamMembers.clear();
    while(q.next()){
        item = new QListWidgetItem(
                    QIcon(":/images/icons/nocall.png"),
                    QString("%1 %2 (%3)")
                        .arg(q.value(0).toString()).arg(q.value(1).toString()).arg(q.value(2).toString()),
                    ui->teamList
                    );
        ui->teamList->addItem(item);
        teamMembers.append(Member(-1,CALL_DISCONNECT,q.value(3).toString()));
    }

}
开发者ID:DavideMalvezzi,项目名称:EscorpioEvo15-DAQSystem,代码行数:58,代码来源:viewutilities.cpp

示例8: if

FormAgregarServicio::FormAgregarServicio( QWidget* parent )
: EVentana( parent ), Ui::FormAgregarServPeluqueriaBase()
{
	setupUi(this);
	setObjectName( "FormAgregarServicio" );
	setWindowTitle( "Agregar Nuevo Servicio de Peluqueria" );
	setWindowIcon( QIcon( ":/imagenes/pelu.gif" ) );

	this->addAction( new EActCerrar( this ) );

	QSqlQueryModel *modeloMascota = new QSqlQueryModel( CBMascota );
	if( QSqlDatabase::database().driverName() == "QSQLITE" )
	{
		modeloMascota->setQuery( "SELECT m.id, m.nombre||' - '||d.apellido||', '||d.nombre FROM mascota m, dueno d WHERE m.id_dueno = d.id ORDER BY 2" );
	}
	else if( QSqlDatabase::database().driverName() == "QMYSQL" )
	{
		modeloMascota->setQuery( "SELECT m.id, CONCAT( CONCAT( CONCAT( CONCAT( m.nombre, \" - \" ), d.apellido ), \", \" ), d.nombre ) FROM mascota m, dueno d WHERE m.id_dueno = d.id ORDER BY 2" );
	}
	CBMascota->setModel( modeloMascota );
	CBMascota->setModelColumn( 1 );
	CBMascota->setCurrentIndex( -1 );
	connect( CBMascota, SIGNAL( currentIndexChanged( int ) ), this, SLOT( cambioIndice( int ) ) );

	CWFecha->setMaximumDate( QDate::currentDate() );
	CWFecha->setSelectionMode( QCalendarWidget::SingleSelection );

	PBAgregar->setIcon( QIcon( ":/imagenes/add.png" ) );
	PBAgregar->setShortcut( QKeySequence( "Ctrl+a" ) );
	PBAgregar->setText( "&Agregar" );
	PBBorrar->setIcon( QIcon( ":/imagenes/borrar.png" ) );
	PBBorrar->setShortcut( QKeySequence( "Ctrl+L" ) );
	PBBorrar->setText( "&Limpiar" );

	modeloPeluqueria = new MPeluqueria( this, false );
	modeloPeluqueria->setSolo_lectura( true );
	preferencias *p = preferencias::getInstancia();
	modeloPeluqueria->setLimite( p->value( "General\\limite", 5 ).toInt() );
	modeloPeluqueria->setSort( 4, Qt::DescendingOrder );
 	modeloPeluqueria->setEditStrategy( QSqlTableModel::OnRowChange );
	TVHistorial->setModel( modeloPeluqueria );
	TVHistorial->hideColumn( 0 );
	TVHistorial->hideColumn( 1 );
	TVHistorial->resizeColumnsToContents();

	connect( PBAgregar, SIGNAL( clicked() ), this, SLOT( agregar() ) );
	connect( PBBorrar , SIGNAL( clicked() ), this, SLOT( borrar()  ) );

	QCompleter *completador = new QCompleter( LEDescripcion );
	QSqlQueryModel *modeloDescripciones = new QSqlQueryModel( completador );
	modeloDescripciones->setQuery( "SELECT DISTINCT descripcion FROM peluqueria" );
	completador->setModel( modeloDescripciones );
	LEDescripcion->setCompleter( completador );
}
开发者ID:chungote,项目名称:gestotux,代码行数:54,代码来源:formagregarservicio.cpp

示例9: if

FormListaPeluqueria::FormListaPeluqueria( QWidget* parent )
: EVentana( parent ), Ui::FormListadoPeluqueriaBase()
{
	setupUi(this);
	setObjectName( "lista_servicios" );
	setWindowTitle( "Listado de servicios brindados" );
	setWindowIcon( QIcon( ":/imagenes/pelu.gif" ) );

	this->addAction( new EActCerrar( this ) );
	QAction *ActAgregar = new QAction( "Agregar", this );
	ActAgregar->setIcon( QIcon( ":/imagenes/add.png" ) );
	ActAgregar->setShortcut( QKeySequence( "Ctrl+a" ) );
	DigiFauno *digifauno = qobject_cast<DigiFauno *>(parent);
        connect( ActAgregar, SIGNAL( triggered() ), this, SLOT( agregarServicioPeluqueria() ) );
	this->addAction( ActAgregar );

	QAction *ActBorrar = new QAction( "Borrar", this );
	ActBorrar->setIcon( QIcon( ":/imagenes/eliminar.png" ) );
	ActBorrar->setShortcut( QKeySequence( "Ctrl+b" ) );
	connect( ActBorrar, SIGNAL( triggered() ), this, SLOT( borrar() ) );
	this->addAction( ActBorrar );

	modelo = new MPeluqueria( TVPeluqueria, true );
	modelo->setEditStrategy( QSqlTableModel::OnRowChange );
	TVPeluqueria->setModel( modelo );
	modelo->select();
	TVPeluqueria->setSelectionBehavior( QAbstractItemView::SelectRows );
	TVPeluqueria->resizeColumnsToContents();
	TVPeluqueria->hideColumn( 0 );
	TVPeluqueria->setSortingEnabled( true );

	GBFiltrado->setChecked( false );

	QSqlQueryModel *modeloMascota = new QSqlQueryModel( CBMascota );
	if( QSqlDatabase::database().driverName() == "QSQLITE" )
	{
		modeloMascota->setQuery( "SELECT m.id, m.nombre||' - '||d.apellido||', '||d.nombre FROM mascota m, dueno d WHERE m.id_dueno = d.id" );
	}
	else if( QSqlDatabase::database().driverName() == "QMYSQL" )
	{
		modeloMascota->setQuery( "SELECT m.id, CONCAT( CONCAT( CONCAT( CONCAT( m.nombre, \" - \" ), d.apellido ), \", \" ), d.nombre ) FROM mascota m, dueno d WHERE m.id_dueno = d.id" );
	}
	CBMascota->setModel( modeloMascota );
	CBMascota->setModelColumn( 1 );
	CBMascota->setCurrentIndex( -1 );

	connect( GBFiltrado, SIGNAL( toggled ( bool )              ), this, SLOT( cambioEstadoGrupo( bool )    ) );
	connect( ChBMascota, SIGNAL( stateChanged ( int )          ), this, SLOT( cambioEstadoMascota( int )   ) );
	connect( ChBFecha  , SIGNAL( stateChanged ( int )          ), this, SLOT( cambioEstadoFecha( int )     ) );
	connect( CBMascota , SIGNAL( currentIndexChanged( int )    ), this, SLOT( cambioIndice( int )          ) );
	connect( DEFecha   , SIGNAL( dateChanged ( const QDate & ) ), this, SLOT( cambioFecha( const QDate & ) ) );

	///@todo Agregar calculo de fecha maxima y minima desde la tabla para limitar el filtrado
}
开发者ID:chungote,项目名称:gestotux,代码行数:54,代码来源:formlistapeluqueria.cpp

示例10: refreshCategories

void AddressWindowImpl::refreshCategories() {
	qDebug("AddressWindowImpl::refreshCategories");
	QSqlQueryModel *query = new QSqlQueryModel();
	query->setQuery("SELECT category FROM Addresses2Categories WHERE address_id="+currentRecord.value("id").toString());
	if(query->lastError().isValid()) qDebug() << query->lastError();
	categoryList->setModel(query);
	
	query = new QSqlQueryModel();
	query->setQuery("SELECT DISTINCT category FROM Addresses2Categories");
	if(query->lastError().isValid()) qDebug() << query->lastError();
	newCategoryCombo->setModel(query);
}//end refreshCategories
开发者ID:arandomuser,项目名称:singpolyma,代码行数:12,代码来源:addresswindowimpl.cpp

示例11: refreshTrackAndVehicle

void MainWindow::refreshTrackAndVehicle(){
    int tindex = ui->comboTrack->currentIndex();
    int vindex = ui->comboVehicle->currentIndex();
    QSqlQueryModel *trackModel = (QSqlQueryModel*)ui->comboTrack->model();
    QSqlQueryModel *vehicleModel = (QSqlQueryModel*)ui->comboVehicle->model();
    trackModel->setQuery("SELECT IDCircuito, Nome FROM Circuito", MainWindow::database);
    vehicleModel->setQuery("SELECT IDVeicolo, Nome FROM Veicolo", MainWindow::database);
    ui->comboTrack->setModelColumn(1);
    ui->comboVehicle->setModelColumn(1);
    ui->comboTrack->setCurrentIndex(tindex);
    ui->comboVehicle->setCurrentIndex(vindex);

}
开发者ID:DavideMalvezzi,项目名称:EscorpioEvo15-DAQSystem,代码行数:13,代码来源:mainwindow.cpp

示例12: QDialog

frmConfigurar_terminal::frmConfigurar_terminal(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::frmConfigurar_terminal)
{
    ui->setupUi(this);
    QSqlQueryModel *series = new QSqlQueryModel(this);
    series->setQuery("select serie from series",Configuracion_global->empresaDB);
    ui->cboserie->setModel(series);
    ui->cboUsuarioActivo->setModel(Configuracion_global->usuarios_model);
    ui->cboUsuarioActivo->setModelColumn(1);
    QSqlQueryModel *cajas = new QSqlQueryModel(this);
    cajas->setQuery("select desc_caja from cajas",Configuracion_global->empresaDB);
    ui->cbocaja->setModel(cajas);

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

示例13: 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

示例14: on_showAllBtn_clicked

void EvictionWindow::on_showAllBtn_clicked()
{
    DataBase db;
    db.connectionOpen();

    QSqlQuery query;
    query.prepare("select * from clients");
    query.exec();

    QSqlQueryModel * model = new QSqlQueryModel();
    model->setQuery(query);
    model->QSqlQueryModel::setHeaderData(0, Qt::Horizontal, "ID");
    model->QSqlQueryModel::setHeaderData(1, Qt::Horizontal, "Имя");
    model->QSqlQueryModel::setHeaderData(2, Qt::Horizontal, "Фамилия");
    model->QSqlQueryModel::setHeaderData(3, Qt::Horizontal, "Паспорт");
    model->QSqlQueryModel::setHeaderData(4, Qt::Horizontal, "Количество дней");
    model->QSqlQueryModel::setHeaderData(5, Qt::Horizontal, "Дата посления");
    model->QSqlQueryModel::setHeaderData(6, Qt::Horizontal, "№ комнаты");
    model->QSqlQueryModel::setHeaderData(7, Qt::Horizontal, "Тип комнаты");
    ui->tableView->setModel(model);
    ui->tableView->resizeColumnToContents(4);
    ui->tableView->resizeColumnToContents(5);

    db.connectionClose();
}
开发者ID:hmlON,项目名称:HotelAdministrator,代码行数:25,代码来源:evictionwindow.cpp

示例15: QDialog

activityhome::activityhome(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::activityhome)
{
    ui->setupUi(this);

    ui->myName->setText(getName());
    ui->courseName->setText(getCourseName());
    ui->activityName->setText(getActivityName());

    QSqlQueryModel *model = new QSqlQueryModel();

    QSqlQuery qry;
    QSqlQuery cts;

    cts.prepare("select studentID from CoursesToStudent where courseID = ?");
    cts.addBindValue(courseid);
    cts.exec();

    qry.prepare("select studentName from Students where studentID = ?");

    qry.exec();
    model->setQuery(qry);
    ui->studentList->setModel(model);
}
开发者ID:pointnotfoe,项目名称:275_group5_SourceSeven,代码行数:25,代码来源:activityhome.cpp


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