本文整理汇总了C++中QSqlRelationalTableModel::removeColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlRelationalTableModel::removeColumn方法的具体用法?C++ QSqlRelationalTableModel::removeColumn怎么用?C++ QSqlRelationalTableModel::removeColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlRelationalTableModel
的用法示例。
在下文中一共展示了QSqlRelationalTableModel::removeColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: QMainWindow
/*
** public:
*/
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, m_timer(new QBasicTimer)
, m_dataProvider(new DataProvider(this))
, m_dialogSettings(0) // Guarded by QPointer
, m_dialogAbout(0) // Guarded by QPointer
{
qDebug() << Q_FUNC_INFO;
/*
m_dataModel = new QStandardItemModel(this);
m_dataModel->setColumnCount(5);
*/
setupUi(this);
/*
QStringList labels;
labels << tr("Show name") << tr("Episode name")
<< tr("Season #") << tr("Episode #") << tr("Date");
m_dataModel->setHorizontalHeaderLabels(labels);
// showsTableView->setModel(m_dataModel);
showsTableView->setModel(DbInterface::instance().readEpisodes());
showsTableView->verticalHeader()->hide();
showsTableView->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
showsTableView->horizontalHeader()->setStretchLastSection(true);
showsTableView->horizontalHeader()->setCascadingSectionResizes(true);
showsTableView->horizontalHeader()->setHighlightSections(true);
showsTableView->horizontalHeader()->setMovable(true);
srand(QTime::currentTime().toString("hhmmsszzz").toUInt());
// Fill with random stuff
for (int i=0; i<30; ++i) {
m_dataModel->setItem(i, 0, new QStandardItem(QString("show_%1").arg(i)));
m_dataModel->setItem(i, 1, new QStandardItem(QString("episode_%1").arg(i)));
m_dataModel->setItem(i, 2, new QStandardItem(QString("%1").arg(rand()%10+1)));
m_dataModel->setItem(i, 3, new QStandardItem(QString("%1").arg(rand()%24+1)));
QDate rndDate = QDate::currentDate().addDays(i);
m_dataModel->setItem(i, 4, new QStandardItem(rndDate.toString("yyyy/MM/dd")));
}
*/
setWindowTitle(QString("nextShows - v%1").arg(NEXTSHOWS_VERSION));
statusBar()->showMessage(tr("nextShows started"), 1000*3);
// TEMPORARY CODE FOR TESTING ////////////////////////////////////////////
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "NS_View");
db.setDatabaseName("ns.db");
db.open();
QSqlRelationalTableModel *model = new QSqlRelationalTableModel(this, db);
model->setTable("T_Episodes");
model->setRelation(model->fieldIndex("shows_id"),
QSqlRelation("T_Shows", "idT_Shows", "ShowName"));
model->setSort(model->fieldIndex("Date"), Qt::AscendingOrder);
model->select();
QStringList hideFields;
hideFields << "idT_Episodes" << "ProdNumber" << "EpisodeCount"
<< "EpisodeUrl" << "isSpecial";
foreach (QString field, hideFields) {
model->removeColumn(model->fieldIndex(field));
}