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


C++ QCanvasItemList::first方法代码示例

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


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

示例1: contentsMousePressEvent

void SkeletonCanvasView::contentsMousePressEvent( QMouseEvent *e )
{
    // a list of all items underneath the mouse when it was pressed
    QCanvasItemList list = canvas()->collisions(e->pos());

    // the RTTI of a QCanvasSprite is 1...
    if ( !list.isEmpty() && list.first()->rtti() == 1 )
    {
        // ...which means we can safely cast to a Bone pointer.
        Bone *sphere = (Bone*)list.first();

        // hit() will return false it we hit the transparent corners
        // of the planet image.
        if ( sphere->hit( e->pos() ) )
        {
            Moving = sphere;
            canvas()->setAdvancePeriod( -1 );  // stops the animation when dragging
            MovingStart = e->pos();
            Moving->setZ( 2 );  // raises the current item above other items when dragging.
            // (This in not really necessary here, since we have just one item.)

            Timer->start( 10, false );  // start the timer
        }
    }

}
开发者ID:BackupTheBerlios,项目名称:lesetaje-svn,代码行数:26,代码来源:skeletoncanvasview.cpp

示例2: contentsMouseReleaseEvent

void KLBoard::contentsMouseReleaseEvent(QMouseEvent *e)
{
    if ( e->button()!=LeftButton || blocked ) return;
    QCanvasItemList list = canvas()->collisions(e->pos());
    if ( list.count()==0 ) return;

    QCanvasSprite *spr = static_cast<QCanvasSprite *>(list.first());
    Coord c = findSprite(spr);
    field.fill(0);
    addRemoved = findGroup(field, c);
    if ( addRemoved>=2 ) {
        if ( state!=Normal ) {
            state = Normal;
            emit firstBlockClicked();
        }
        blocked = true;
        _beforeRemove(true);
    }
}
开发者ID:,项目名称:,代码行数:19,代码来源:


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