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


C++ QTableView::setEditTriggers方法代码示例

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


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

示例1: setupTabs

void AddressWidget::setupTabs()
{
    QStringList groups;
    groups << "ABC" << "DEF" << "GHI" << "JKL" << "MNO" << "PQR" << "STU" << "VW" << "XYZ";

    for (int i = 0; i < groups.size(); ++i) {
        QString str = groups.at(i);
        
        proxyModel = new QSortFilterProxyModel(this);
        proxyModel->setSourceModel(table);
        proxyModel->setDynamicSortFilter(true);
    
        QTableView *tableView = new QTableView;
        tableView->setModel(proxyModel);
        tableView->setSortingEnabled(true);
        tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
        tableView->horizontalHeader()->setStretchLastSection(true);
        tableView->verticalHeader()->hide();
        tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
        tableView->setSelectionMode(QAbstractItemView::SingleSelection);

        QString newStr = QString("^[%1].*").arg(str);

        proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive));
        proxyModel->setFilterKeyColumn(0);
        proxyModel->sort(0, Qt::AscendingOrder);
    
        connect(tableView->selectionModel(),
            SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SIGNAL(selectionChanged(QItemSelection)));

        addTab(tableView, str);
    }
}
开发者ID:mimino,项目名称:math_tool,代码行数:34,代码来源:addresswidget.cpp

示例2: QWidget

QTableView *ProcessDetail::createTableView(const QString &label)
{
    QWidget *tableViewContainer = new QWidget();

    QVBoxLayout *viewLayout = new QVBoxLayout();
    viewLayout->setMargin(0);
    tableViewContainer->setLayout(viewLayout);

    QLabel *gcLabel = new QLabel(label);
    viewLayout->addWidget(gcLabel);
    QTableView *tableView = new QTableView();
    tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    viewLayout->addWidget(tableView);
    horizontalTables->addWidget(tableViewContainer);
    return tableView;
}
开发者ID:code-mancers,项目名称:rbkit-client,代码行数:16,代码来源:processdetail.cpp

示例3: on_pbPosition_clicked

void SettingsDialog::on_pbPosition_clicked()
{
  QScopedPointer< Gui::Dialog > dialog(new Gui::Dialog(Gui::Dialog::CenterOfScreen,this));
  PositionModel *model = new PositionModel(dialog.data());
  QTableView *view = new QTableView(dialog.data());
  QItemSelectionModel *selectionModel = new QItemSelectionModel(model,dialog.data());

  dialog->setWindowTitle(tr("Set position"));

  QVBoxLayout *layout = new QVBoxLayout;
  QDialogButtonBox *dialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                                                         Qt::Horizontal,dialog.data());
  connect(dialogButtons,SIGNAL(accepted()),dialog.data(),SLOT(accept()));
  connect(dialogButtons,SIGNAL(rejected()),dialog.data(),SLOT(reject()));

  view->setModel(model);
  view->setItemDelegateForColumn(0,new PositionLabelDelegate);
  view->setItemDelegateForColumn(1,new PositionDelegate(QApplication::palette()));
  view->setSelectionBehavior(QAbstractItemView::SelectRows);
  view->setSelectionMode(QAbstractItemView::SingleSelection);
  view->setSelectionModel(selectionModel);
  view->verticalHeader()->setVisible(false);
  view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
  view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
  view->setEditTriggers(QAbstractItemView::NoEditTriggers);

  layout->addWidget(view);
  layout->addWidget(dialogButtons);
  dialog->setLayout(layout);
  dialog->resize(700,500);
  connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeColumnsToContents()));
  connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeRowsToContents()));

  selectionModel->select(model->index(pbPosition->property("wallPosition").toInt(),0),
                         QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
  view->scrollTo(model->index(pbPosition->property("wallPosition").toInt(),0));
  if (dialog->exec() == QDialog::Accepted)
  {
    Wally::Application::Position p = static_cast<Wally::Application::Position> (selectionModel->currentIndex().row());
    pbPosition->setProperty("wallPosition",static_cast<int> (p));
    pbPosition->setText(positionToString(p).replace("&","&&"));
    settingsModified();
  }
}
开发者ID:kamawanu,项目名称:wally-imported,代码行数:44,代码来源:settings.cpp

示例4: 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));
        }
    }
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:41,代码来源:sqldatabase.cpp

示例5: QMainWindow

StaticView::StaticView(QWidget *parent) : QMainWindow(parent){
	QWidget *cwg= new QWidget(this);
	QVBoxLayout *vbox = new QVBoxLayout(cwg);
{
	QHBoxLayout *hbox = new QHBoxLayout();
	QTableView *view = new QTableView(cwg);
		view->setEditTriggers(QAbstractItemView::NoEditTriggers);
		hbox->addWidget(view);

		vbox->addLayout(hbox);
}
{
		QHBoxLayout *hbox = new QHBoxLayout();
		hbox->addStretch();
		{
			QPushButton *ppb = new QPushButton("&Refresh",cwg);
			hbox->addWidget(ppb);
		}
		vbox->addLayout(hbox);
	}
	this->setCentralWidget(cwg);
	setWindowIcon(QIcon(":image/tomatoicon.ico"));
    setWindowTitle("Pomidorka Static");
}
开发者ID:winorun,项目名称:gpp-gui-qt4-pomidorka,代码行数:24,代码来源:staticview.cpp

示例6: QWidget

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    resize(400,300);
    if(connect())
    {
        QTableView *view = new QTableView(this);
        QSqlRelationalTableModel *model = new QSqlRelationalTableModel;//要先有数据才能创建model,也就是先连接数据库局
        view->setGeometry(0,0,400,300);

        view->setModel(model);
        model->setTable("student");
        model->setSort(0,Qt::AscendingOrder);
//        model->setHeaderData(0,Qt::Horizontal,"Name");//from 0
//        model->setHeaderData(1,Qt::Horizontal,"Age");
//        model->setHeaderData(2,Qt::Horizontal,"likes");
        model->setRelation(3,QSqlRelation("city","id","name"));
        model->select();


//        view->setModel(model);

        view->setSelectionMode(QAbstractItemView::SingleSelection);//设置选择模式
        view->setSelectionBehavior(QAbstractItemView::SelectRows);//选择行
//        view->resizeColumnsToContents();//tiaozhengziti
        view->setEditTriggers(QAbstractItemView::DoubleClicked);//不可编辑?

        QHeaderView *header =  view->horizontalHeader();
        header->setStretchLastSection(true);
        view->setItemDelegate(new QSqlRelationalDelegate(view));
//        QHeaderView *head = view->verticalHeader();
//        head->setStretchLastSection(true);
//        view->show();
//        this?->show();
    }
}
开发者ID:youngjeff,项目名称:qt,代码行数:36,代码来源:widget.cpp

示例7: QWidget

FenetreGraphique::FenetreGraphique(QWidget* parent): QWidget(parent){

    //Fentre principale
    this->setWindowTitle(QString("Project Calendar"));
    //setFixedSize(1200,800);
    setFixedSize(900,600);
    //qApp->setStyleSheet("QTableView{border:1px solid red;}");

    //Onglets saisie et affichage
    onglets = new QTabWidget(this);
    //onglets->setGeometry(10,10,1180,780);
    onglets->setGeometry(10,10,980,540);
    pageSaisie = new QWidget;
    pageAffichage = new QWidget;
    pageExport = new QWidget;

    //Page Saisie//////////////////////////////////////////////////////////////////////////////////////////////
    layoutPageSaisiePrincipal = new QHBoxLayout;

    //GroupBox selectionprojet + treeview
    layoutProjetTV = new QVBoxLayout;
    gBProjetTV = new QGroupBox(this);
    gBProjetTV->setTitle("Projets");
    gBProjetTV->setFixedWidth(300);

    //onglets creation projet, tache, event
    supportOngletsCreation = new QWidget;
    ongletsNiveau2 = new QTabWidget(supportOngletsCreation);
    ongletsNiveau2->setGeometry(0,10,540,420);
    //ongletsNiveau2->setGeometry(0,10,840,720);
    pageCreationprojet = new QWidget;
    pageTacheUnitaire = new QWidget;
    pageTacheComposite = new QWidget;
    initialisationTabPTUTC();

    //Liste des projets
    bNouveauProjet = new QPushButton("Nouveau projet");
    menuDeroulantProjets = new QComboBox;
    initialisationMenuProjet();

    //Treeview
    modelTreeView = new QStandardItemModel;
    vueTreeView = new QTreeView;
    vueTreeView->setModel(modelTreeView);
    vueTreeView->setHeaderHidden(true);
    vueTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);

    //creation projets
    layoutCreationProjet1 = new QHBoxLayout;
    layoutCreationProjet2 = new QHBoxLayout;
    layoutCreationProjet3 = new QHBoxLayout;
    layoutCreationProjet4 = new QHBoxLayout;
    layoutCreationProjet5 = new QHBoxLayout;
    layoutCreationProjet = new QVBoxLayout;

    labelNomProjet = new QLabel("Nom du projet :");    
    nomProjet = new QLabel("");
    labelProjetDateDispo = new QLabel("Date de disponibilité : ");
    projetDateDispo = new QLabel("");
    labelProjetEcheance = new QLabel("Echéance du projet :");
    projetEcheance = new QLabel("");
    bCreerTacheUProjet = new QPushButton("Creer tache unitaire");
    bCreerTacheCProjet = new QPushButton("Creer tache composite");
    bModifierProjet = new QPushButton("Modifier le projet");
    bdetruireProjet = new QPushButton("Supprimer");

    //creation tache
    layoutCreationTache1 = new QHBoxLayout;
    layoutCreationTache2 = new QHBoxLayout;
    layoutCreationTache3 = new QHBoxLayout;
    layoutCreationTache4 = new QHBoxLayout;
    layoutCreationTache5 = new QHBoxLayout;
    layoutCreationTache6 = new QHBoxLayout;
    layoutCreationTache7 = new QHBoxLayout;
    layoutCreationTache8 = new QHBoxLayout;
    layoutCreationTache = new QVBoxLayout;

    //Fenetre TacheUnitaire
    labelIdentificateurTache = new QLabel("Identificateur de la tache : ");
    identificateurTache = new QLabel("");
    preemptiveTache = new QCheckBox("Preemptive");
    preemptiveTache->setDisabled(true);
    titreTacheLabel = new QLabel("Titre de la tache :");
    titreTache = new QLabel("");
    labelTacheEtat = new QLabel("Etat :");
    tacheEtat = new QLabel("");
    labelDisponibiliteTache = new QLabel("Date de disponibilité :");
    disponibiliteTache = new QLabel("");
    labelTacheEcheance = new QLabel("Date d'écheance :");
    tacheEcheance = new QLabel("");
    labelTacheDuree = new QLabel("Durée :");
    tacheDuree = new QLabel("");
    labelPrecedenceTacheU = new QLabel("Tâches précédentes");
    modelePrecedenceTacheU = new QStringListModel(QStringList(""));
    vuePrecedenceTacheU = new QListView;
    vuePrecedenceTacheU->setModel(modelePrecedenceTacheU);
    vuePrecedenceTacheU->setEditTriggers(QAbstractItemView::NoEditTriggers);
    bModifierTacheU = new QPushButton("Modifier");
    bSupprimerTacheU = new QPushButton("Supprimer");

//.........这里部分代码省略.........
开发者ID:TerisseNicolas,项目名称:LO21-Calendar,代码行数:101,代码来源:fenetregraphique.cpp

示例8: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

// ![0]
    QStandardItemModel model(0, 1);
    populateListModel(&model);
// ![0]

    QWidget toplevel;
    QVBoxLayout *layout = new QVBoxLayout(&toplevel);

// ![1]
    QMaemo5ValueButton *button1 = new QMaemo5ValueButton("Value besides text");
    button1->setValueLayout(QMaemo5ValueButton::ValueBesideText);
    QMaemo5ListPickSelector *selector1 = new QMaemo5ListPickSelector;
    selector1->setModel(&model);
    // not setting the current index means that the value is empty.
    button1->setPickSelector(selector1);
// ![1]

// ![2]
    QStandardItemModel tableModel(0, 0);
    populateTableModel(&tableModel);
// ![2]

// ![3]
    QMaemo5ValueButton *button2 = new QMaemo5ValueButton("Value under text");
    button2->setValueLayout(QMaemo5ValueButton::ValueUnderText);
    QMaemo5ListPickSelector *selector2 = new QMaemo5ListPickSelector;
    selector2->setModel(&tableModel);
    selector2->setModelColumn(2);
    selector2->setCurrentIndex(5);
    button2->setPickSelector(selector2);
// ![3]

    // create a custom view we want a table view instead of a list
    QTableView *view = new QTableView();
    view->setEditTriggers(QAbstractItemView::NoEditTriggers);

    // try to get a sensible column width and row height
    view->setModel(&tableModel); // set the model in order to get correct column widths
    view->resizeColumnsToContents();
    view->resizeRowsToContents();
    view->horizontalHeader()->setStretchLastSection(true);

    view->verticalHeader()->setVisible(false);
    view->horizontalHeader()->setVisible(false);
    view->setSelectionBehavior(QAbstractItemView::SelectRows);
    view->setSelectionMode(QAbstractItemView::SingleSelection);

    // five rows should be visible as a default
    if (view->verticalHeader()->sectionSize(0)>0)
        view->setMinimumHeight(view->verticalHeader()->sectionSize(0) * 5);

    QMaemo5ValueButton *button3 = new QMaemo5ValueButton("Value centered under text");
    button3->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered);
    QMaemo5ListPickSelector *selector3 = new QMaemo5ListPickSelector;
    selector3->setModel(&tableModel);
    selector3->setModelColumn(2);
    selector3->setView(view); // set our new custom view
    selector3->setCurrentIndex(0);
    button3->setPickSelector(selector3);

    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);

    toplevel.show();

    return app.exec();
}
开发者ID:agamez,项目名称:qt-x11-maemo,代码行数:72,代码来源:main.cpp

示例9: QMainWindow

    OLD_MAIN(QWidget* pParent = nullptr)
        : QMainWindow(pParent)
    {
        Q_INIT_RESOURCE(Resources);

        // Settings persistence
        ReadSettings();

        // Appearance LUT
        PlayerApperances appearances;

        // Build player table model from file
        PlayerTableModel* playerTableModel = new PlayerTableModel(this);
        playerTableModel->LoadHittingProjections(appearances);
        playerTableModel->LoadPitchingProjections(appearances);
        playerTableModel->CalculateHittingScores();
        playerTableModel->CalculatePitchingScores();
        playerTableModel->InitializeTargetValues();

        // Draft delegate
        DraftDelegate* draftDelegate = new DraftDelegate(playerTableModel);
        LinkDelegate* linkDelegate = new LinkDelegate(this);
        TagDelegate* tagDelegate = new TagDelegate(this);

        // Hitter sort-model
        PlayerSortFilterProxyModel* hitterSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Hitter);
        hitterSortFilterProxyModel->setSourceModel(playerTableModel);
        hitterSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);

        // Hitter table view
        QTableView* hitterTableView = MakeTableView(hitterSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
        hitterTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);

        // Context menu
        QMenu* contextMenu = new QMenu();
        contextMenu->addAction("&Remove Player");

        // Apply to hitter table view
        hitterTableView->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(hitterTableView, &QWidget::customContextMenuRequested, [=](const QPoint& pos) {
            QPoint globalPos = hitterTableView->mapToGlobal(pos);
            QAction* selectedItem = contextMenu->exec(globalPos);
            if (selectedItem) {
                auto proxyIndex = hitterTableView->indexAt(pos);
                auto srcIndex = hitterSortFilterProxyModel->mapToSource(proxyIndex);
                playerTableModel->RemovePlayer(srcIndex.row());
            }
        });

        // Pitcher sort-model
        PlayerSortFilterProxyModel* pitcherSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Pitcher);
        pitcherSortFilterProxyModel->setSourceModel(playerTableModel);
        pitcherSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);
        
        // Pitcher table view
        QTableView* pitcherTableView = MakeTableView(pitcherSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
        pitcherTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);

        // Top/Bottom splitter
        QSplitter* topBottomSplitter = new QSplitter(Qt::Vertical);
        topBottomSplitter->setContentsMargins(5, 5, 5, 5);

        // Hitter/Pitcher tab View
        enum PlayerTableTabs { Hitters, Pitchers, Unknown };
        QTabWidget* hitterPitcherTabs = new QTabWidget(this);
        hitterPitcherTabs->insertTab(PlayerTableTabs::Hitters, hitterTableView, "Hitters");
        hitterPitcherTabs->insertTab(PlayerTableTabs::Pitchers, pitcherTableView, "Pitchers");
        topBottomSplitter->addWidget(hitterPitcherTabs);

        // Tab lookup helper
        auto CaterogyToTab = [](uint32_t catergory) 
        {
            switch (catergory)
            {
            case Player::Hitter:
                return PlayerTableTabs::Hitters;
            case Player::Pitcher:
                return PlayerTableTabs::Pitchers;
            default:
                return PlayerTableTabs::Unknown;
            }
        };

        // Drafted filter action
        QAction* filterDrafted = new QAction(this);
        connect(filterDrafted, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
        connect(filterDrafted, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
        filterDrafted->setText(tr("Drafted"));
        filterDrafted->setToolTip("Toggle Drafted Players");
        filterDrafted->setCheckable(true);
        filterDrafted->toggle();

        QAction* filterReplacement = new QAction(this);
        connect(filterReplacement, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement);
//.........这里部分代码省略.........
开发者ID:kspagnoli,项目名称:fbb,代码行数:101,代码来源:old_main.cpp

示例10: addProject

void ContributoriesWidget::addProject(QPair<Project*, Rate>* p)
{
    if(p == 0) {
        _modelProjects->append();
    } else {
        _modelProjects->append(*p);
    }
    QTableView* view = new QTableView();
    _modelsContributories << new WdgModels::ContributoriesTableModel();
    view->setModel(_modelsContributories.last());
    view->setEditTriggers(QAbstractItemView::DoubleClicked);
    view->setItemDelegateForColumn(0, new Delegates::TextareaDelegate());
    view->setItemDelegateForColumn(1, new Delegates::TextareaDelegate());
    view->setItemDelegateForColumn(2, new Delegates::DoubleSpinBoxDelegate());
    view->setItemDelegateForColumn(3, new Delegates::UnitComboDelegate());

    connect(view->itemDelegateForColumn(3),
            SIGNAL(closeEditor(QWidget*)),
            SLOT(updatePrice()));
    connect(view->itemDelegateForColumn(2),
            SIGNAL(closeEditor(QWidget*)),
            SLOT(updatePrice()));
    connect(view->itemDelegateForColumn(1),
            SIGNAL(closeEditor(QWidget*)),
            SLOT(updatePrice()));



    ui->stack->insertWidget(ui->stack->count(), view);
    responsiveContributoriesTable(view);
    emit updateUi();
}
开发者ID:FACT-Team,项目名称:FactDev,代码行数:32,代码来源:contributorieswidget.cpp


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