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


C++ QSqlRelationalTableModel::removeColumn方法代码示例

本文整理汇总了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;
}
开发者ID:itumashyk,项目名称:TofP,代码行数:33,代码来源:userform.cpp

示例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));
    }
开发者ID:gilcn,项目名称:nextshows,代码行数:66,代码来源:mainwindow.cpp


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