本文整理汇总了C++中QSqlRelationalTableModel::setFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRelationalTableModel::setFilter方法的具体用法?C++ QSqlRelationalTableModel::setFilter怎么用?C++ QSqlRelationalTableModel::setFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlRelationalTableModel
的用法示例。
在下文中一共展示了QSqlRelationalTableModel::setFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTableModels
void UserForm:: createTableModels()
{
QSqlRelationalTableModel* model = new QSqlRelationalTableModel();
model->setTable("good");
model->setRelation(Producer, QSqlRelation("company", "companyid", "name"));
model->setRelation(Catalog, QSqlRelation("catalog", "id", "name"));
model->setHeaderData(Producer, Qt::Horizontal, "Producer");
model->setHeaderData(Name, Qt::Horizontal, "Name");
model->setHeaderData(Price, Qt::Horizontal, "Price, $");
model->setHeaderData(Description, Qt::Horizontal, "Description");
model->setHeaderData(Catalog, Qt::Horizontal, "Catalog");
model->setFilter("catalog_id IS NOT NULL");
// model->removeColumn(5);
model->select();
productsModel = model;
model = new QSqlRelationalTableModel();
model->setTable("`order`");
model->setRelation(goodId, QSqlRelation("good", "goodid", "name"));
model->setFilter("user_login='" + TofPApplication::getUserLogin() + "'");
model->select();
model->setEditStrategy(QSqlTableModel::OnRowChange);
model->removeColumn(3);
model->removeColumn(2);
model->setHeaderData(orderId, Qt::Horizontal, "Order #");
model->setHeaderData(goodId, Qt::Horizontal, "Product");
model->setHeaderData(date, Qt::Horizontal, "Date");
model->setHeaderData(address, Qt::Horizontal, "Address to deliver");
ordersModel = model;
}
示例2: loadCargas
void Carga::loadCargas(QDate start, QDate end){
QSqlRelationalTableModel *model = new QSqlRelationalTableModel(0, QSqlDatabase::database());
model->setTable("cargas");
model->setRelation(2, QSqlRelation("cereales", "id", "cereal"));
model->setRelation(15, QSqlRelation("transportista", "cuit", "nombre"));
model->setRelation(8, QSqlRelation("cliente", "cuit", "nombre"));
model->setRelation(5, QSqlRelation("localizacion", "id", "lugar"));
model->setRelation(7, QSqlRelation("tipo_operacion", "id", "name"));
model->setRelation(11, QSqlRelation("boolean", "id", "name"));
model->setRelation(12, QSqlRelation("boolean", "id", "name"));
model->setRelation(13, QSqlRelation("boolean", "id", "name"));
model->setRelation(14, QSqlRelation("boolean", "id", "name"));
model->setRelation(19, QSqlRelation("boolean", "id", "name"));
QString filter = "fecha BETWEEN '" + start.toString("yyyy-MM-dd") + "' AND '" + end.toString("yyyy-MM-dd") + "'";
model->setFilter(filter);
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Fecha"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("Grano"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("Cosecha"));
model->setHeaderData(4, Qt::Horizontal, QObject::tr("Kilos"));
model->setHeaderData(5, Qt::Horizontal, QObject::tr("Origen"));
model->setHeaderData(6, Qt::Horizontal, QObject::tr("N° C porte"));
model->setHeaderData(7, Qt::Horizontal, QObject::tr("Tipo"));
model->setHeaderData(8, Qt::Horizontal, QObject::tr("Cliente"));
model->setHeaderData(9, Qt::Horizontal, QObject::tr("Tarifa a cobrar"));
model->setHeaderData(10, Qt::Horizontal, QObject::tr("Tarifa a pagar"));
model->setHeaderData(11, Qt::Horizontal, QObject::tr("Se cobra"));
model->setHeaderData(12, Qt::Horizontal, QObject::tr("Se paga"));
model->setHeaderData(13, Qt::Horizontal, QObject::tr("Pagado"));
model->setHeaderData(14, Qt::Horizontal, QObject::tr("Cobrado"));
model->setHeaderData(15, Qt::Horizontal, QObject::tr("Transportista"));
model->setHeaderData(16, Qt::Horizontal, QObject::tr("Observaciones"));
model->setHeaderData(17, Qt::Horizontal, QObject::tr("Origen"));
model->setHeaderData(18, Qt::Horizontal, QObject::tr("Destino"));
model->setHeaderData(19, Qt::Horizontal, QObject::tr("En depósito"));
model->select();
ui->cargas->setModel(model);
ui->cargas->setItemDelegate(new QSqlRelationalDelegate(ui->cargas));
ui->cargas->setSortingEnabled(true);
ui->cargas->setVisible(false);
ui->cargas->resizeColumnsToContents();
ui->cargas->setVisible(true);
// OCULTAR COLUMNAS CARGAS
ui->cargas->setColumnHidden(0,true);
ui->pushButton_3->setDisabled(true);
}
示例3: timer
void BadgeWindow::timer()
{
DialogTimer dialogTimer;
bool saveRequest;
QString taskName;
QTime elapsedTime;
saveRequest = dialogTimer.getTaskInfo(taskName, elapsedTime);
if (saveRequest) {
DialogTask dialog;
QSqlRelationalTableModel *taskModel;
taskModel = new QSqlRelationalTableModel();
taskModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
taskModel->setTable("task");
qDebug() << "Day" << QDate::currentDate().toString("yyyy-MM-dd") << endl;
taskModel->setFilter("day='" + QDate::currentDate().toString("yyyy-MM-dd") + "'");
//taskModel.setEditStrategy(QSqlTableModel::OnFieldChange);
taskModel->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
taskModel->setHeaderData(1, Qt::Horizontal, QObject::tr("Date"));
taskModel->setHeaderData(2, Qt::Horizontal, QObject::tr("Elapsed"));
//taskModel->setHeaderData(3, Qt::Horizontal, QObject::tr("Attivita'"));
taskModel->setRelation(3, QSqlRelation("attivita", "id", "attivita"));
taskModel->select();
// TODO: if current date don't exist create it
dialog.openTask("Task", "Elapsed", taskModel, QDate::currentDate(), "task", elapsedTime, taskName);
delete taskModel;
}
}