本文整理汇总了C++中QSqlTableModel::columnCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlTableModel::columnCount方法的具体用法?C++ QSqlTableModel::columnCount怎么用?C++ QSqlTableModel::columnCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlTableModel
的用法示例。
在下文中一共展示了QSqlTableModel::columnCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initBorrowTableView
void AdminDialog::initBorrowTableView()
{
QSqlTableModel *model = new QSqlTableModel(this,Tool::getInstance()->getDb());
model->setTable("borrow");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select(); //选取整个表的所有行
model->setFilter("isreturn=0");
model->removeColumn(model->columnCount()-1);
model->removeColumn(model->columnCount()-1);
model->setHeaderData(0,Qt::Horizontal,"借阅编号");
model->setHeaderData(1,Qt::Horizontal,"图书编号");
model->setHeaderData(2,Qt::Horizontal,"读者编号");
model->setHeaderData(3,Qt::Horizontal,"剩余续借次数");
model->setHeaderData(4,Qt::Horizontal,"借阅时间");
model->setHeaderData(5,Qt::Horizontal,"应还时间");
ui->tv3->setModel(model);
ui->tv3->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
示例2: on_pushBtnSel_clicked
void SelectLiftDlg::on_pushBtnSel_clicked()
{
int curRow = ui->tableView->currentIndex().row();
if(curRow<0)
{
QMessageBox::warning(this,"警告","请先选择电梯!",QMessageBox::Yes);
return;
}
QSqlTableModel *modelTable = new QSqlTableModel(this);
modelTable->setTable("tableLift");
modelTable->select();
for(int i=0;i<modelTable->columnCount();i++)
{
QModelIndex index = modelTable->index(curRow,i);
arrValues.push_back(modelTable->data(index).toString());
}
accept();
}
示例3: QSqlQueryModel_snippets
void QSqlQueryModel_snippets()
{
{
//! [16]
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery("SELECT name, salary FROM employee");
model->setHeaderData(0, Qt::Horizontal, tr("Name"));
model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
//! [17]
QTableView *view = new QTableView;
//! [17] //! [18]
view->setModel(model);
//! [18] //! [19]
view->show();
//! [16] //! [19] //! [20]
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
//! [20]
}
//! [21]
QSqlTableModel model;
model.setTable("employee");
model.select();
int salary = model.record(4).value("salary").toInt();
//! [21]
Q_UNUSED(salary);
{
//! [22]
int salary = model.data(model.index(4, 2)).toInt();
//! [22]
Q_UNUSED(salary);
}
for (int row = 0; row < model.rowCount(); ++row) {
for (int col = 0; col < model.columnCount(); ++col) {
qDebug() << model.data(model.index(row, col));
}
}
}