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


C++ QTreeWidget::itemAt方法代码示例

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


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

示例1: imageSearch


//.........这里部分代码省略.........
    connect(mSearchClearButton, SIGNAL(clicked()), this, SLOT(clearSearchLine()));


    // Misc
    mVisibilityIconVisibleForGroups = true;
    mVisibilityIconVisibleForAssets = true;
    mDeletionIconVisibleForGroups = true;
    mDeletionIconVisibleForAssets = true;

    // Layout
    mSearchLayout->addWidget(mSearchLabel, 1);
    mSearchLayout->addWidget(mSearchLine, 2000);
    mSearchLayout->addWidget(mSearchClearButton, 1);
    setVisibilitySearchWidgets(false);
    mainLayout->addLayout(mSearchLayout, 1);
    mainLayout->addLayout(mTreeLayout, 2000);
    setLayout(mainLayout);
}

//****************************************************************************/
QtSceneViewWidget::~QtSceneViewWidget(void)
{
    // Delete all QtAssetGroups in mAssetGroupMap
    foreach (QtAssetGroup* group, mAssetGroupMap)
        delete group;

    mAssetGroupMap.clear();

}

//****************************************************************************/
bool QtSceneViewWidget::eventFilter(QObject* object, QEvent* event)
{
    QMouseEvent* mouseEvent = (QMouseEvent*) event;
    switch ((int) event->type())
    {
    case QEvent::MouseButtonPress:
        mouseClickHandler(mouseEvent);
        break;
    }
    return QObject::eventFilter(object, event);
}

//****************************************************************************/
void QtSceneViewWidget::mouseClickHandler(QMouseEvent* event)
{
    switch ((int) event->button())
    {
    case Qt::LeftButton:
    {
        // Get the selected item of the visible sceneview
        QTreeWidget* sceneView = getCurrentVisibleScene();
        if (sceneView)
        {
            QTreeWidgetItem* item = sceneView->itemAt(event->pos());
            int col = sceneView->columnAt(event->pos().x());
            if (itemIsGroup(item))
            {
                if (col == TOOL_SCENEVIEW_COLUMN_GROUP_CLOSE)
                {
                    handleDeletionOfGroup(sceneView, item);
                    return;
                }
                else if (col == TOOL_SCENEVIEW_COLUMN_GROUP_VISIBILITY)
                {
                    // Toggle visibility
                    toggleVisibilityOfGroup(item);
                }

                int groupId = getGroupIdOfGroupItem(item);
                emit groupSelected(sceneView, groupId);
            }
            else if (itemIsAsset(item))
            {
                if (col == TOOL_SCENEVIEW_COLUMN_ASSET_CLOSE)
                {
                    handleDeletionOfAsset(sceneView, item);
                    return;
                }
                else if (col == TOOL_SCENEVIEW_COLUMN_ASSET_VISIBILITY)
                {
                    // Toggle visibility
                    toggleVisibilityOfAsset(item);
                }

                int groupId = getGroupIdOfAssetItem(item);
                int assetId = getAssetIdOfAssetItem(item);
                emit assetSelected(sceneView, groupId, assetId);
            }
        }
    }
    break;

    case Qt::RightButton:
    {
        // TODO
    }
    break;
    }
}
开发者ID:galek,项目名称:Magus,代码行数:101,代码来源:tool_sceneviewwidget.cpp

示例2: showSurfacesMenu

void MainWindow::showSurfacesMenu(const QPoint &pos)
{
    QTreeWidget *tree = m_ui.surfacesTreeWidget;
    QTreeWidgetItem *item = tree->itemAt(pos);
    if (!item) {
        return;
    }

    QMenu menu(tr("Surfaces"), this);

    QAction *act = menu.addAction(tr("View Image"));
    act->setStatusTip(tr("View the currently selected surface"));
    connect(act, SIGNAL(triggered()),
            SLOT(showSelectedSurface()));

    act = menu.addAction(tr("Save Image"));
    act->setStatusTip(tr("Save the currently selected surface"));
    connect(act, SIGNAL(triggered()),
            SLOT(saveSelectedSurface()));

    menu.exec(tree->viewport()->mapToGlobal(pos));
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:22,代码来源:mainwindow.cpp


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