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


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

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


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

示例1: QDialog

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

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

    QSqlQueryModel *model = new QSqlQueryModel();

    QSqlQuery cts;

    qDebug() << actid;
    cts.prepare("select CoursesToStudent.studentName, ModifiedBy.userType "
                "from CoursesToStudent "
                "left join ModifiedBy "
                "on CoursesToStudent.studentID = ModifiedBy.studentID "
                "where ModifiedBy.activityID = ?");
    cts.addBindValue(actid);
    cts.exec();

    model->setQuery(cts);
    model->setHeaderData(0, Qt::Horizontal, tr("Student Name"));
    model->setHeaderData(1, Qt::Horizontal, tr("Modified By"));

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

示例2: getComponetsLot

void HModifyProd::getComponetsLot()
{
    QSqlQuery q(db);
  //  idlot=ui->tvLots->model()->index(ui->tvLots->currentIndex().row(),0).data(0).toInt();
    QString sql="select operazioni.ID,operazioni.IDlotto,lotdef.lot,prodotti.ID,prodotti.descrizione,operazioni.quantita,unita_di_misura.ID,unita_di_misura.descrizione from operazioni,lotdef,prodotti,unita_di_misura where prodotti.ID=operazioni.IDprodotto and lotdef.ID=operazioni.IDlotto and unita_di_misura.ID=operazioni.um and  operazioni.ID in (SELECT operazione from composizione_lot where ID_lotto=:lotid )order by operazioni.quantita desc";
    QSqlQueryModel *qmod = new QSqlQueryModel();
    q.prepare(sql);
    q.bindValue(":lotid",QVariant(idlot));
    q.exec();
    qmod->setQuery(q);
   // // qDebug()<<q.lastQuery();

    ui->tvDetails->setModel(qmod);
    connect(ui->tvDetails->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(getLotRowData()));
    //// qDebug()<<q.lastError().text();
    qmod->setHeaderData(4,Qt::Horizontal,QObject::tr("Ingrediente"));
    qmod->setHeaderData(5,Qt::Horizontal,QObject::tr("Quantità"));
    ui->tvDetails->setColumnHidden(0,true);
    ui->tvDetails->setColumnHidden(1,true);
    ui->tvDetails->setColumnHidden(3,true);
    ui->tvDetails->setColumnHidden(6,true);


    QString lbtxt;
    lbtxt=ui->tvLots->model()->index(ui->tvLots->currentIndex().row(),1).data(0).toString();
    lbtxt.append(" - ");
    lbtxt.append(ui->tvLots->model()->index(ui->tvLots->currentIndex().row(),2).data(0).toString());
    ui->lbProd->setText(lbtxt);



// qDebug()<<QString::number(idlot);


}
开发者ID:fblabs,项目名称:hamlet-mod-sancon,代码行数:35,代码来源:hmodifyprod.cpp

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

示例4: on_btnLogin_clicked

void MainWindow::on_btnLogin_clicked()
{
    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery("SELECT * FROM users");
    model->setHeaderData(0, Qt::Horizontal, tr("Name"));
    model->setHeaderData(0, Qt::Horizontal, tr("Password"));
    model->setHeaderData(0, Qt::Horizontal, tr("Type"));

    QString username = ui->txtUserName->text();
    QString password = ui->txtPassWord->text();

    bool success = loginManager->Login(username, password);

    if (success)
    {
        MainMenu *menu = new MainMenu(0, loginManager);
        menu->show();
        this->destroy();
        //QTableView *view = new QTableView;
        //view->setWindowTitle("Users");
        //view->resizeColumnsToContents();
        //view->resizeRowsToContents();
        //view->setModel(model);
        //view->show();
        //view->resize(640, 480);
    }
}
开发者ID:ErrAza,项目名称:tortuga,代码行数:27,代码来源:mainwindow.cpp

示例5: on_tableView_clicked

void frmClients::on_tableView_clicked(const QModelIndex &index)
{
    ui->ClientTabs->setVisible(true);

    ui->FIOEdit->setDisabled(true);
    ui->Nom_Edit->setDisabled(true);
    ui->dateEdit->setDisabled(true);
    ui->InfoEdit->setDisabled(true);
    ui->Pol->setDisabled(true);
    ui->OtkudaEdit->setDisabled(true);

    QModelIndex ID = ui->tableView->model()->index(index.row(),3);
    IDClients = ID.data().toInt();

    frm->UpdateClients(IDClients);
    QSqlQuery query;
    query.prepare("SELECT FIO, nom_tel, Date_R, info, pol  FROM Clients WHERE Clients.ID = :ID");
    query.bindValue(":ID",IDClients);
    query.exec();
    while (query.next()){
        ui->FIOEdit->setText(query.value(0).toString());
        ui->Nom_Edit->setText(query.value(1).toString());
        ui->dateEdit->setDateCalendar(QDate::fromString(query.value(2).toString(),"dd.MM.yyyy"));
        ui->InfoEdit->setText(query.value(3).toString());
        ui->Pol->setCurrentIndex(query.value(4).toInt());
   }
    query.prepare("SELECT "
                  " Clients_history.DATE_USLUGI, "
                  " USLUGI.NAME, "
                  " SUM(Clients_history.SUMMA) AS SUMMA, "
                  " Clients_history.NUMBER "
                  "FROM CLIENTS_HISTORY INNER JOIN USLUGI ON CLIENTS_HISTORY.ID_USLUGA = USLUGI.ID "
                  "WHERE Clients_history.ID_CLIENT = :ID "
                  "GROUP BY"
                  " Clients_history.DATE_USLUGI, "
                  " USLUGI.NAME, "
                  " Clients_history.NUMBER "
                  "ORDER BY "
                  " Clients_history.NUMBER");
    query.bindValue(":ID",IDClients);
    query.exec();
    qDebug() << query.lastError();
    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery(query);
    model->setHeaderData(0,Qt::Horizontal,QObject::tr("Дата"));
    model->setHeaderData(1,Qt::Horizontal,QObject::tr("Услуга"));
    model->setHeaderData(2,Qt::Horizontal,QObject::tr("Сумма"));
    model->setHeaderData(3,Qt::Horizontal,QObject::tr("Ном. док."));
    ui->tClient_history->setModel(model);
    ui->tClient_history->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
}
开发者ID:sergey4475,项目名称:profi,代码行数:51,代码来源:frmclients.cpp

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

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

示例8: QDialog

mantenimientoTitulo::mantenimientoTitulo(int idUnidad, QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::mantenimientoTitulo)
{
    m_ui->setupUi(this);

    m_ui->btmTitulo->setChecked(true);


    Persistencia::Persistencia *servicioPersistencia=new Persistencia(idUnidad);

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

    //model->setTable("titulo");
    //model->select();

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Titulo Material Bibliografico"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("ISBN"));
    m_ui->titulos->setModel(model);
    m_ui->titulos->alternatingRowColors();
    //m_ui->titulos->hideColumn(0);
    m_ui->titulos->horizontalHeader()->resizeSection(0, 350);
    m_ui->titulos->setSelectionMode(QAbstractItemView::SingleSelection);
    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,代码行数:31,代码来源:mantenimientotitulo.cpp

示例9: refreshMasterList

//! Loads all items from inventory into the table view in the window.
void wndInventoryControl::refreshMasterList( void )
{
    QSqlQuery selectInventory;

    // If the filter category is all, do not condition SELECT query
    if ( _pUI->cmbCategoryFilter->currentText() == "[All]" )
    {
        selectInventory.prepare( "SELECT * FROM inventory" );
    }  
    else // Otherwise, append the filter text to a condition in the query
    {
        selectInventory.prepare( "SELECT * FROM inventory WHERE category=?" );
        selectInventory.addBindValue( _pUI->cmbCategoryFilter->currentText() );
    }

    if ( _pDB->query( selectInventory ) )
    {
        // Create a SQL Query Model for the QTableView
        QSqlQueryModel *model = new QSqlQueryModel;
        model->setQuery( selectInventory );

        // Set header values
        model->setHeaderData( 0, Qt::Horizontal, tr( "Barcode" ) );
        model->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );
        model->setHeaderData( 2, Qt::Horizontal, tr( "Description" ) );
        model->setHeaderData( 3, Qt::Horizontal, tr( "Category" ) );

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

示例10: QSqlQueryModel

QSqlQueryModel * Mainwindow::modelback(QWidget * centralwidget)
{
	QSqlQueryModel * model = new QSqlQueryModel(centralwidget);
   	model->setQuery("select Num,Price from Room where Num in(select Num from Room where Live = 0)");
	model->setHeaderData(0, Qt::Horizontal, QObject::tr("RoomNum"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Price"));
    return model;
}
开发者ID:frankyue,项目名称:phm,代码行数:8,代码来源:mainwindow.cpp

示例11: cast

QSqlQueryModel * DatabaseHandler::getStuk4Associations() {
    QSqlQueryModel * model = new QSqlQueryModel;
    model->setQuery("SELECT code, category, description FROM stuk4_codes "
    		"where type='ASS' AND code!='0' ORDER BY cast(code as integer)");
    model->setHeaderData(0, Qt::Horizontal, "Code");
    model->setHeaderData(1, Qt::Horizontal, "Kategorie");
    model->setHeaderData(2, Qt::Horizontal, "Beschreibung");
    return model;
 }
开发者ID:ifaoe,项目名称:2014-10-Bird-View,代码行数:9,代码来源:DatabaseHandler.cpp

示例12: favoriteSongs_Show

//点击喜爱歌曲按钮
void MusicWindow::favoriteSongs_Show()
{
    QString loginName = "1";
    QString loginName2 = "2";
    QFile file("C:/Qt/Qt5.4.1/projects/QT_MusicPlayer/fiiles/user.txt");
    QSqlQueryModel *model = new QSqlQueryModel;

    if(!file.open(QFile::ReadOnly | QFile::Text)) //只读打开
    {
        QMessageBox::critical(0, tr("Tips"), tr("Local user file can not OPEN!"));
        return;
    }
    QTextStream in(&file);
    loginName = in.readLine();
    file.close();

    QFile file_previous("C:/Qt/Qt5.4.1/projects/QT_MusicPlayer/fiiles/user_previous.txt");
    QTextStream in_previous(&file_previous);
    if(!file_previous.open(QFile::ReadOnly | QFile::Text)) //只读打开
    {
        QMessageBox::critical(0, tr("Tips"), tr("Local user file can not OPEN!"));
        return;
    }

    loginName2 = in_previous.readLine();
    file_previous.close();

    if((loginName == loginName2) & (! loginName.isEmpty()))
    {
        LoginName = loginName;
    }
    else
    {
        QMessageBox::information(0, tr("Tips"), tr("You can check your favorite songs after you have logined!"));
        return;
    }

    model->setQuery(QString("select * from user_%1").arg(LoginName));
    model->setHeaderData(0, Qt::Horizontal, tr("The name of songs"));
    model->setHeaderData(1, Qt::Horizontal, tr("The number of mark"));
    ui->favoriteView->setModel(model);
    ui->favoriteView->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); //表头居中
    ui->favoriteView->setColumnWidth(0, 355);//设置固定列宽
    ui->favoriteView->setColumnWidth(1, 355);

    titlePalette = ui->favoriteButton->palette();
    titlePalette.setColor(QPalette::ButtonText, Qt::red);
    ui->favoriteButton->setPalette(titlePalette);
    titlePalette.setColor(QPalette::ButtonText,Qt::white);
    ui->storeButton->setPalette(titlePalette);
    ui->browserButton->setPalette(titlePalette);

    ui->webView->hide();
    ui->storeView->hide();
    ui->favoriteView->show();
}
开发者ID:NoJsJa,项目名称:Qt_MusicPlayer,代码行数:57,代码来源:musicwindow.cpp

示例13: refreshColaborador

void frmColaborador::refreshColaborador(){
    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery("SELECT pk_colaborador, col_nome, col_email FROM db_colaborador", ColaboradorDatabase::getInstance());
    model->setHeaderData(0,Qt::Horizontal, tr("ID"));
    model->setHeaderData(1,Qt::Horizontal, tr("Nome"));
    model->setHeaderData(2,Qt::Horizontal, tr("Email"));
    ui->tbColaborador->setModel(model);
    ui->tbColaborador->setAlternatingRowColors(true);
    ui->tbColaborador->show();
}
开发者ID:kenreurison,项目名称:prestacao,代码行数:10,代码来源:frmcolaborador.cpp

示例14: search

void BadgeWindow::search()
{
    DialogSearch searchDialog;
    int total;
    QString message;
    QString hours;
    QString minutes;
    QDate begin;
    QDate end;
    bool ok;
    QString own;

    //total = searchDialog.totalHours(ok);
    if (searchDialog.range(begin, end, own)) {

        DialogStatistics statistics;
        int overTime;

        BadgeData data;
        QMap <QString, QTime> activities;
        QSqlQueryModel *model;
        QString query;
        model = new QSqlQueryModel();

        ok = true;
        total = data.totalTime(begin, end, overTime, /*activities,*/ workingTime, days);

        query = "select attivita.attivita, (sum((strftime('%H',time) * 3600) + (strftime('%M',time) * 60)) / 3600),   ((sum((strftime('%H',time) * 3600) + (strftime('%M',time) * 60)) % 3600) /60) from attivita join task on (attivita.id=task.how) where task.day >= '"+ begin.toString("yyyy-MM-dd") + "' AND task.day <= '" + end.toString("yyyy-MM-dd") + "'";

        if (own.size() > 0)
             query += " AND task.own='" + own + "'";

        query += " group by attivita.attivita";

        model->setQuery(query);
        model->setHeaderData(0, Qt::Horizontal, tr("Task"));
        model->setHeaderData(1, Qt::Horizontal, tr("Hours"));
        model->setHeaderData(2, Qt::Horizontal, tr("Minutes"));



        statistics.showStatistics(begin, end, total, overTime, model);



        delete model;
/*
        hours.setNum(total.hour());
        minutes.setNum(total.minute());
        message = "Total time is: " + hours + " hours and " + minutes + " minutes";
        QMessageBox::information(this, tr("Badge"), tr(message.toLatin1()));*/

    }

}
开发者ID:BackupTheBerlios,项目名称:qbadgetask,代码行数:55,代码来源:badgewindow.cpp

示例15: on_pushButton_clicked

void Search::on_pushButton_clicked()
{
    QSqlQueryModel *model = new QSqlQueryModel;
        model->setQuery("SELECT firstname, lastname, class, roll_no,STATUS FROM  student");
        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,代码行数:11,代码来源:search.cpp


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