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


C++ QTreeView类代码示例

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


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

示例1: setHeader

int TreeView::setHeader(lua_State * L) // ( QHeaderView * header )
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QHeaderView* header = QtObject<QHeaderView>::check( L, 2);
	obj->setHeader( header );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlTreeView.cpp

示例2: QCOMPARE

void tst_QDirModel::task196768_sorting()
{
    //this task showed that the persistent model indexes got corrupted when sorting
    QString path = SRCDIR;

    QDirModel model;

    /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory
       and we don't add QDir::Hidden. But as QDirModel is deprecated, we decided not to fix it. */
    model.setFilter(QDir::AllEntries | QDir::Hidden | QDir::AllDirs);

    QTreeView view;
    QPersistentModelIndex index = model.index(path);
    view.setModel(&model);
    QModelIndex index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setRootIndex(index);
    index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setCurrentIndex(index);
    index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setSortingEnabled(true);
    index2 = model.index(path);

#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
    QEXPECT_FAIL("", "QTBUG-43818", Continue);
#endif

    QCOMPARE(index.data(), index2.data());
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:31,代码来源:tst_qdirmodel.cpp

示例3: QWidget

ActionInspectorWidget::ActionInspectorWidget(QWidget *parent)
  : QWidget(parent)
{
  QAbstractItemModel *actionModel = ObjectBroker::model("com.kdab.GammaRay.ActionModel");

  QSortFilterProxyModel *searchFilterProxy = new KRecursiveFilterProxyModel(this);
  searchFilterProxy->setSourceModel(actionModel);
  searchFilterProxy->setDynamicSortFilter(true);
  m_proxy = searchFilterProxy;

  QVBoxLayout *vbox = new QVBoxLayout(this);

  KFilterProxySearchLine *objectSearchLine = new KFilterProxySearchLine(this);
  objectSearchLine->setProxy(searchFilterProxy);
  vbox->addWidget(objectSearchLine);

  QTreeView *objectTreeView = new QTreeView(this);
  objectTreeView->setModel(searchFilterProxy);
  objectTreeView->setSortingEnabled(true);
  objectTreeView->sortByColumn(ActionModel::ShortcutsPropColumn);
  objectTreeView->setRootIsDecorated(false);
  vbox->addWidget(objectTreeView);
  connect(objectTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(triggerAction(QModelIndex)));
  mObjectTreeView = objectTreeView;
}
开发者ID:pangpangpang3,项目名称:GammaRay,代码行数:25,代码来源:actioninspectorwidget.cpp

示例4: setExpanded

int TreeView::setExpanded(lua_State * L) // ( const QModelIndex & index, bool expanded )
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* index = QtValue<QModelIndex>::check( L, 2 );
	obj->setExpanded( *index, Util::toBool( L, 3 ) );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlTreeView.cpp

示例5: QWidget

LessThanWidget::LessThanWidget(QWidget* parent, Qt::WindowFlags f)
    : QWidget(parent, f)
{
  QLabel *explanation = new QLabel(this);
  explanation->setText("The yellow items are 'less than' the selected item according to QModelIndex::operator<().\n"
                       "The red items are greater than the selected item (i.e, not less than and not equal).");

  m_coloredTreeModel = new ColoredTreeModel(this);
  QTreeView *treeView = new QTreeView(this);
  treeView->setModel(m_coloredTreeModel);
  treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
  treeView->setSelectionMode(QTreeView::SingleSelection);

  m_coloredTreeModel->setSelectionModel(treeView->selectionModel());

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->addWidget(explanation);
  layout->addWidget(treeView);

  insertGrid(QList<int>());
  insertGrid(QList<int>() << 2);
  insertGrid(QList<int>() << 3);
  insertGrid(QList<int>() << 4);
  insertGrid(QList<int>() << 3 << 2);
  insertGrid(QList<int>() << 3 << 3);
  insertGrid(QList<int>() << 3 << 4);
}
开发者ID:vasi,项目名称:kdelibs,代码行数:27,代码来源:lessthanwidget.cpp

示例6: idx

void View::Private::slotCollapsed(const QModelIndex& _idx)
{
    QTreeView* tw = qobject_cast<QTreeView*>(leftWidget);
    if (!tw) return;

    bool blocked = gfxview->blockSignals( true );

    QModelIndex idx( _idx );
    const QAbstractItemModel* model = leftWidget->model();
    const QModelIndex pidx = ganttProxyModel.mapFromSource(idx);
    bool isMulti = false;
    for ( QModelIndex treewalkidx = pidx; treewalkidx.isValid(); treewalkidx = treewalkidx.parent() ) {
        if ( treewalkidx.data( ItemTypeRole ).toInt() == TypeMulti
             && !gfxview->rowController()->isRowExpanded( treewalkidx ) ) {
            isMulti = true;
            break;
        }
    }

    if ( !isMulti ) {
        for ( int i = 0; i < model->rowCount( idx ); ++i ) {
            gfxview->deleteSubtree( ganttProxyModel.index( i, 0, pidx ) );
        }
    } else {
        gfxview->updateRow(pidx);
    }
    //qDebug() << "Looking to update from " << idx;
    while ( ( idx=tw->indexBelow( idx ) ) != QModelIndex() &&
            gfxview->rowController()->isRowVisible( ganttProxyModel.mapFromSource(idx) ) ) {
        const QModelIndex proxyidx( ganttProxyModel.mapFromSource( idx ) );
        gfxview->updateRow(proxyidx);
    }
    gfxview->blockSignals( blocked );
    gfxview->updateSceneRect();
}
开发者ID:KDE,项目名称:kdiagram,代码行数:35,代码来源:kganttview.cpp

示例7: QWidget

GraphViewer::GraphViewer(ProbeInterface *probe, QWidget *parent)
    : QWidget(parent),
      mWidget(new GraphWidget(this)),
      mProbeIface(probe)
{
    QSortFilterProxyModel *objectFilter = new KRecursiveFilterProxyModel(this);
    objectFilter->setSourceModel(probe->objectTreeModel());
    objectFilter->setDynamicSortFilter(true);

    QVBoxLayout *vbox = new QVBoxLayout;
    KFilterProxySearchLine *objectSearchLine = new KFilterProxySearchLine(this);
    objectSearchLine->setProxy(objectFilter);
    vbox->addWidget(objectSearchLine);
    QTreeView *objectTreeView = new QTreeView(this);
    objectTreeView->setModel(objectFilter);
    objectTreeView->setSortingEnabled(true);
    vbox->addWidget(objectTreeView);
    connect(objectTreeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
            SLOT(handleRowChanged(QModelIndex)));
    mObjectTreeView = objectTreeView;

    QWidget *treeViewWidget = new QWidget(this);
    treeViewWidget->setLayout(vbox);

    QSplitter *splitter = new QSplitter(this);
    splitter->addWidget(treeViewWidget);
    splitter->addWidget(mWidget);
    QHBoxLayout *hbox = new QHBoxLayout(this);
    hbox->addWidget(splitter);

    QMetaObject::invokeMethod(this, "delayedInit", Qt::QueuedConnection);
}
开发者ID:frankosterfeld,项目名称:GammaRay,代码行数:32,代码来源:objectvisualizer.cpp

示例8: QDialog

AddBookmarkDialog::AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent, BookmarksManager *bookmarkManager)
    : QDialog(parent)
    , m_url(url)
    , m_bookmarksManager(bookmarkManager)
{
    setWindowFlags(Qt::Sheet);
    if (!m_bookmarksManager)
        m_bookmarksManager = BrowserApplication::bookmarksManager();
    setupUi(this);
    QTreeView *view = new QTreeView(this);
    m_proxyModel = new AddBookmarkProxyModel(this);
    BookmarksModel *model = m_bookmarksManager->bookmarksModel();
    m_proxyModel->setSourceModel(model);
    view->setModel(m_proxyModel);
    view->expandAll();
    view->header()->setStretchLastSection(true);
    view->header()->hide();
    view->setItemsExpandable(false);
    view->setRootIsDecorated(false);
    view->setIndentation(10);
    location->setModel(m_proxyModel);
    view->show();
    location->setView(view);
    BookmarkNode *menu = m_bookmarksManager->menu();
    QModelIndex idx = m_proxyModel->mapFromSource(model->index(menu));
    view->setCurrentIndex(idx);
    location->setCurrentIndex(idx.row());
    name->setText(title);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:29,代码来源:bookmarks.cpp

示例9: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);

	m_pModel = new CBvhModel(this) ;

	QHBoxLayout *pLayout = new QHBoxLayout(ui->centralWidget) ;
	QSplitter *pSplitter = new QSplitter(ui->centralWidget) ;
	pLayout->addWidget(pSplitter);

	QTreeView *pTreeView = new QTreeView(this) ;
	pTreeView->setModel(m_pModel);
	pTreeView->header()->setHidden(true) ;

	m_pGlView = new CGLView(ui->centralWidget) ;
	m_pGlView->show();

	pSplitter->addWidget(pTreeView) ;
	pSplitter->addWidget(m_pGlView) ;

	ui->centralWidget->setLayout(pLayout) ;

	setAcceptDrops(true) ;

	QTimer *pTimer = new QTimer(this) ;
	pTimer->setInterval(1000/30);
	connect(pTimer, SIGNAL(timeout()), this, SLOT(slot_timerEvent())) ;
	m_oldTime.start() ;
	pTimer->start();
	m_bRead = false ;
}
开发者ID:chocoball,项目名称:bvhviewer,代码行数:33,代码来源:mainwindow.cpp

示例10: main

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

  // Open the addressbook file in the working directory 
  QFile file("addressbook.csv");
  if ( !file.open(QIODevice::ReadOnly|QIODevice::Text) )
	  return 1;

  // Read its content into a string
  QString addresses = QString::fromUtf8(file.readAll());
  AddressbookModel model(addresses);

  QListView listView;
  listView.setModel(&model);
  listView.setModelColumn(0);
  listView.show();

  QTreeView treeView;
  treeView.setModel(&model);
  treeView.show();

  QTableView tableView;
  tableView.setModel(&model);
  tableView.show();

  return app.exec();
}
开发者ID:asieriko,项目名称:custommodel,代码行数:28,代码来源:main.cpp

示例11: main

int main(int argc, char** argv) {
  QApplication app(argc, argv);
  const QString name("CConf Demo");
  app.setApplicationDisplayName(name);

  // CConf::Context *ctxt = new CConf::Context();
  // ctxt->addFile("example.json");
  // ctxt->addFile("example2.json");

  // TestModel model;

  QStandardItemModel model;

  QStandardItem item(QString("my item"));

  QList<QStandardItem*> myList;
  myList.append(&item);

  model.appendRow(myList);

  QTreeView* confView = new QTreeView();
  confView->setModel(&model);

  QMainWindow* win = new QMainWindow();
  win->addToolBar(name);
  win->setCentralWidget(confView);
  win->show();

  return app.exec();
}
开发者ID:justbuchanan,项目名称:CConf,代码行数:30,代码来源:test2.cpp

示例12: main

//! [0] //! [1]
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QSplitter *splitter = new QSplitter;

//! [2] //! [3]
    QFileSystemModel *model = new QFileSystemModel;
    model->setRootPath(QDir::currentPath());
//! [0] //! [2] //! [4] //! [5]
    QTreeView *tree = new QTreeView(splitter);
//! [3] //! [6]
    tree->setModel(model);
//! [4] //! [6] //! [7]
    tree->setRootIndex(model->index(QDir::currentPath()));
//! [7]

    QListView *list = new QListView(splitter);
    list->setModel(model);
    list->setRootIndex(model->index(QDir::currentPath()));

//! [5]
    QItemSelectionModel *selection = new QItemSelectionModel(model);
    tree->setSelectionModel(selection);
    list->setSelectionModel(selection);

//! [8]
    splitter->setWindowTitle("Two views onto the same file system model");
    splitter->show();
    return app.exec();
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:31,代码来源:main.cpp

示例13: QCompleter

void WorkSheetWidget::setupCompleters()
{
    QTreeView *itemTreeView =  new QTreeView;
    itemModel.setQuery("SELECT Description FROM item");
    pItemCompleter = new QCompleter(&itemModel,this);
    pItemCompleter->setPopup(itemTreeView);
    itemTreeView->setRootIsDecorated(false);
    itemTreeView->header()->hide();
    itemTreeView->header()->setStretchLastSection(false);
    itemTreeView->header()->setResizeMode(0, QHeaderView::ResizeToContents);

    pItemCompleter->setCaseSensitivity(Qt::CaseInsensitive);
    pItemCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
    ui->ItemEdit->setCompleter(pItemCompleter);

    QTreeView *categoryTreeView =  new QTreeView;
    categoryModel.setQuery("SELECT Name FROM category");
    pCategoryCompleter = new QCompleter(&categoryModel, this);
    pCategoryCompleter->setPopup(categoryTreeView);
    categoryTreeView->setRootIsDecorated(false);
    categoryTreeView->header()->hide();
    categoryTreeView->header()->setStretchLastSection(false);
    categoryTreeView->header()->setResizeMode(0, QHeaderView::ResizeToContents);

    pCategoryCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
    pCategoryCompleter->setCaseSensitivity(Qt::CaseInsensitive);
    ui->categoryEdit->setCompleter(pCategoryCompleter);


}
开发者ID:Asitha,项目名称:Estima,代码行数:30,代码来源:worksheetwidget.cpp

示例14: setRowHidden

int TreeView::setRowHidden(lua_State * L) // ( int row, const QModelIndex & parent, bool hide )
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* parent = QtValue<QModelIndex>::check( L, 3 );
	obj->setRowHidden( Util::toInt( L, 2 ), *parent, Util::toBool( L, 4 ) );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlTreeView.cpp

示例15: createToolBar

void GLSLTextEditorWidget::createToolBar(GLSLEditorEditable *editable)
{
    m_outlineCombo = new QComboBox;
    m_outlineCombo->setMinimumContentsLength(22);

    // ### m_outlineCombo->setModel(m_outlineModel);

    QTreeView *treeView = new QTreeView;
    treeView->header()->hide();
    treeView->setItemsExpandable(false);
    treeView->setRootIsDecorated(false);
    m_outlineCombo->setView(treeView);
    treeView->expandAll();

    //m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);

    // Make the combo box prefer to expand
    QSizePolicy policy = m_outlineCombo->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    m_outlineCombo->setSizePolicy(policy);

    QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());

    QList<QAction*> actions = toolBar->actions();
    toolBar->insertWidget(actions.first(), m_outlineCombo);
}
开发者ID:yinyunqiao,项目名称:qtcreator,代码行数:26,代码来源:glsleditor.cpp


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