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


C++ QAbstractItemView::selectionModel方法代码示例

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


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

示例1: clicked

void tst_QColumnView::clicked()
{
    ColumnView view;

    QDirModel model;
    view.setModel(&model);
    view.resize(800,300);
    view.show();

    QModelIndex home = model.index(QDir::homePath());
    QVERIFY(home.isValid());
    view.setCurrentIndex(home);
    QTest::qWait(ANIMATION_DELAY);

    QModelIndex parent = home.parent();
    QVERIFY(parent.isValid());

    qRegisterMetaType<QModelIndex>("QModelIndex");
    QSignalSpy clickedSpy(&view, SIGNAL(clicked(const QModelIndex &)));

    QPoint localPoint = view.visualRect(home).center();
    QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint);
    QCOMPARE(clickedSpy.count(), 1);
    qApp->processEvents();
    
    if (sizeof(qreal) != sizeof(double)) {
        QSKIP("Skipped due to rounding errors", SkipAll);
    }
    
    for (int i = 0; i < view.createdColumns.count(); ++i) {
        QAbstractItemView *column = view.createdColumns.at(i);
        if (column && column->selectionModel() && (column->rootIndex() == home))
                QVERIFY(column->selectionModel()->selectedIndexes().isEmpty());
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:35,代码来源:tst_qcolumnview.cpp

示例2: currentWidget

QList<std::shared_ptr<const UICommon::GameFile>> GameList::GetSelectedGames() const
{
  QAbstractItemView* view;
  QSortFilterProxyModel* proxy;
  if (currentWidget() == m_list)
  {
    view = m_list;
    proxy = m_list_proxy;
  }
  else
  {
    view = m_grid;
    proxy = m_grid_proxy;
  }
  QList<std::shared_ptr<const UICommon::GameFile>> selected_list;
  QItemSelectionModel* sel_model = view->selectionModel();
  if (sel_model->hasSelection())
  {
    QModelIndexList index_list =
        currentWidget() == m_list ? sel_model->selectedRows() : sel_model->selectedIndexes();
    for (const auto& index : index_list)
    {
      QModelIndex model_index = proxy->mapToSource(index);
      selected_list.push_back(m_model->GetGameFile(model_index.row()));
    }
  }
  return selected_list;
}
开发者ID:booto,项目名称:dolphin,代码行数:28,代码来源:GameList.cpp

示例3: verifyCurrentItemAndSelection

 /** A method that simplifies checking a view's current item and selection */
 static void verifyCurrentItemAndSelection(const QAbstractItemView& view, const QModelIndex& expectedCurrent, const QModelIndexList& expectedSelection) {
     QCOMPARE(view.currentIndex(), expectedCurrent);
     const QModelIndexList selectedIndexes = view.selectionModel()->selectedIndexes();
     QCOMPARE(selectedIndexes.count(), expectedSelection.count());
     foreach(const QModelIndex& index, expectedSelection) {
         QVERIFY(selectedIndexes.contains(index));
     }
开发者ID:vishesh,项目名称:kde-baseapps,代码行数:8,代码来源:dolphintreeviewtest.cpp

示例4: openTransactionInLedger

void TransactionView::openTransactionInLedger()
{
    QAbstractItemView *view = transactionView;
    if (!view->selectionModel())
        return;

    QModelIndexList selection = view->selectionModel()->selectedRows(0);
    if (!selection.isEmpty())
    {
        QString url;
        if (fTestNet) {
            url = "http://testnet.MonedaDelEmprendimiento.com/transaction/";
        } else {
            url = "http://ledger.MonedaDelEmprendimiento.com/transaction/";
        }

        url.append(selection.at(0).data(TransactionTableModel::TxIDRole).toString());
        QDesktopServices::openUrl(QUrl(url));
    }
}
开发者ID:Iamhumanareyou,项目名称:EmprendeCoin,代码行数:20,代码来源:transactionview.cpp

示例5: rename

void BookmarksWidget::rename()
{
    QWidget *w = focusWidget();
    QAbstractItemView *view = qobject_cast<QAbstractItemView*>(w);
    if (view) {
        QModelIndexList indexes = view->selectionModel()->selectedIndexes();
        if (indexes.isEmpty())
            return;
        QModelIndex index = indexes.first();
        view->edit(index);
    }
}
开发者ID:denosauro,项目名称:Andromeda,代码行数:12,代码来源:bookmarkswidget.cpp

示例6: copySelection

void OutputWidget::copySelection()
{
    QWidget* widget = currentWidget();
    if( !widget )
        return;
    QAbstractItemView *view = dynamic_cast<QAbstractItemView*>(widget);
    if( !view )
        return;

    QClipboard *cb = QApplication::clipboard();
    QModelIndexList indexes = view->selectionModel()->selectedRows();
    QString content;
    Q_FOREACH( const QModelIndex& index, indexes) {
      content += index.data().toString() + '\n';
    }
开发者ID:mali,项目名称:kdevplatform,代码行数:15,代码来源:outputwidget.cpp

示例7: GetSelectedGame

QString GameList::GetSelectedGame() const
{
	QAbstractItemView* view;
	QSortFilterProxyModel* proxy;
	if (currentWidget() == m_table)
	{
		view = m_table;
		proxy = m_table_proxy;
	}
	else
	{
		view = m_list;
		proxy = m_list_proxy;
	}
	QItemSelectionModel* sel_model = view->selectionModel();
	if (sel_model->hasSelection())
	{
		QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]);
		return m_model->GetPath(model_index.row());
	}
	return QStringLiteral();
}
开发者ID:JMC47,项目名称:dolphin,代码行数:22,代码来源:GameList.cpp

示例8:

std::shared_ptr<const UICommon::GameFile> GameList::GetSelectedGame() const
{
  QAbstractItemView* view;
  QSortFilterProxyModel* proxy;
  if (currentWidget() == m_list)
  {
    view = m_list;
    proxy = m_list_proxy;
  }
  else
  {
    view = m_grid;
    proxy = m_grid_proxy;
  }
  QItemSelectionModel* sel_model = view->selectionModel();
  if (sel_model->hasSelection())
  {
    QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]);
    return m_model->GetGameFile(model_index.row());
  }
  return {};
}
开发者ID:booto,项目名称:dolphin,代码行数:22,代码来源:GameList.cpp

示例9: pixmap


//.........这里部分代码省略.........
            m_pointView, SLOT(toggleDrawCursor()));
    connect(drawAxes, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawAxes()));
    connect(drawGrid, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawGrid()));
    connect(drawAnnotations, SIGNAL(triggered()),
            m_pointView, SLOT(toggleDrawAnnotations()));
    connect(trackballMode, SIGNAL(triggered()),
            m_pointView, SLOT(toggleCameraMode()));
    connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)),
            this, SLOT(geometryRowsInserted(QModelIndex,int,int)));

    //--------------------------------------------------
    // Docked widgets
    // Shader parameters UI
    QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this);
    shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable |
                                  QDockWidget::DockWidgetClosable);
    QWidget* shaderParamsUI = new QWidget(shaderParamsDock);
    shaderParamsDock->setWidget(shaderParamsUI);
    m_pointView->setShaderParamsUIWidget(shaderParamsUI);

    // Shader editor UI
    QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this);
    shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable |
                                  QDockWidget::DockWidgetClosable |
                                  QDockWidget::DockWidgetFloatable);
    QWidget* shaderEditorUI = new QWidget(shaderEditorDock);
    m_shaderEditor = new ShaderEditor(shaderEditorUI);
    QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI);
    shaderEditorLayout->setContentsMargins(2,2,2,2);
    shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1);
    connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show()));
    shaderEditorDock->setWidget(shaderEditorUI);

    shaderMenu->addAction(m_shaderEditor->compileAction());
    connect(m_shaderEditor->compileAction(), SIGNAL(triggered()),
            this, SLOT(compileShaderFile()));

    // TODO: check if this is needed - test shader update functionality
    //connect(m_shaderEditor, SIGNAL(sendShader(QString)),
    //        &m_pointView->shaderProgram(), SLOT(setShader(QString)));

    // Log viewer UI
    QDockWidget* logDock = new QDockWidget(tr("Log"), this);
    logDock->setFeatures(QDockWidget::DockWidgetMovable |
                         QDockWidget::DockWidgetClosable);
    QWidget* logUI = new QWidget(logDock);
    m_logTextView = new LogViewer(logUI);
    m_logTextView->setReadOnly(true);
    m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
    m_logTextView->connectLogger(&g_logger); // connect to global logger
    m_progressBar = new QProgressBar(logUI);
    m_progressBar->setRange(0,100);
    m_progressBar->setValue(0);
    m_progressBar->hide();
    connect(m_fileLoader, SIGNAL(loadStepStarted(QString)),
            this, SLOT(setProgressBarText(QString)));
    connect(m_fileLoader, SIGNAL(loadProgress(int)),
            m_progressBar, SLOT(setValue(int)));
    connect(m_fileLoader, SIGNAL(resetProgress()),
            m_progressBar, SLOT(hide()));
    QVBoxLayout* logUILayout = new QVBoxLayout(logUI);
    //logUILayout->setContentsMargins(2,2,2,2);
    logUILayout->addWidget(m_logTextView);
    logUILayout->addWidget(m_progressBar);
    //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap);
    logDock->setWidget(logUI);

    // Data set list UI
    QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this);
    dataSetDock->setFeatures(QDockWidget::DockWidgetMovable |
                              QDockWidget::DockWidgetClosable |
                              QDockWidget::DockWidgetFloatable);
    DataSetUI* dataSetUI = new DataSetUI(this);
    dataSetDock->setWidget(dataSetUI);
    QAbstractItemView* dataSetOverview = dataSetUI->view();
    dataSetOverview->setModel(m_geometries);
    connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)),
            m_pointView, SLOT(centerOnGeometry(const QModelIndex&)));
    m_pointView->setSelectionModel(dataSetOverview->selectionModel());

    // Set up docked widgets
    addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock);
    addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock);
    addDockWidget(Qt::RightDockWidgetArea, logDock);
    addDockWidget(Qt::RightDockWidgetArea, dataSetDock);
    tabifyDockWidget(logDock, dataSetDock);
    logDock->raise();
    shaderEditorDock->setVisible(false);

    // Add dock widget toggles to view menu
    viewMenu->addSeparator();
    viewMenu->addAction(shaderParamsDock->toggleViewAction());
    viewMenu->addAction(logDock->toggleViewAction());
    viewMenu->addAction(dataSetDock->toggleViewAction());

    // Create custom hook events from CLI at runtime
    m_hookManager = new HookManager(this);
}
开发者ID:nigels-com,项目名称:displaz,代码行数:101,代码来源:PointViewerMainWindow.cpp


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