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


C++ QGraphicsItem::hide方法代码示例

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


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

示例1: hideAllItemsExceptImage

void GraphicsScene::hideAllItemsExceptImage()
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::hideAllItemsExceptImage";

  for (int index = 0; index < QGraphicsScene::items().count(); index++) {
    QGraphicsItem *item = QGraphicsScene::items().at(index);

    if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt() == GRAPHICS_ITEM_TYPE_IMAGE) {

      item->show();

    } else {

      item->hide();

    }
  }
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例2: reinitializeDisplayedItemPosition

void SunMenuItemView::reinitializeDisplayedItemPosition()
{
    qint32 maxWidth = width();
    qint32 maxHeight;
    QGraphicsItem* gi = displayedItem()->graphicsItem();

    //default
    gi->resetTransform();

    // Calculate maxHeight as smaller chord(only for small sweepLengths)
    if (sweepLength() <= 90)
    {
        qreal biggerChord = 2 * (innerRadius() + maxWidth)
                * /*qAbs*/(qSin((M_PI / 180) * sweepLength() / 2));
        qreal smallerChord = 2 * innerRadius()
                * /*qAbs*/(qSin((M_PI / 180) * sweepLength() / 2));
        maxHeight = (0.2 * smallerChord + 1.4 * biggerChord) / 2;
    }
    else
        maxHeight = displayedItem()->maximumHeight();

    //hide item if it too small
    if (maxWidth < 10 || maxHeight < 5)
    {
        gi->hide();
        return;
    }

    QRectF graphicsItemRect;

    if (sweepLength() == 360 && innerRadius() == 0)
    {
        displayedItem()->setMaximumSize(2 * maxWidth /*diameter*/, maxHeight);
        graphicsItemRect = gi->boundingRect();
        gi->setPos(-graphicsItemRect.width() / 2,
                   -graphicsItemRect.height() / 2);

        gi->show();
        return;
    }

    displayedItem()->setMaximumSize(maxWidth - 10, maxHeight);
    graphicsItemRect = gi->boundingRect();

    /////////////////////////////////////////////////////////////////////////////////
    //positioning mDisplayedItem (rotation and coordinates).
    qreal rotationAngle = startAngle() + sweepLength() / 2;

    // Getting distance and angle (polar coordinates) + some centering adjustments
    // We assume that (0,0) item's coordinate is it's top left corner
    //(like QGraphicsSimpleTextItem and QGraphicsProxyWidget).
    qreal angle, distance;
    if (rotationAngle >= 270 || rotationAngle <= 90)
    {
        distance = innerRadius() + maxWidth / 2 - graphicsItemRect.width() / 2;
        angle = rotationAngle
                + (180 / M_PI)
                * qAtan(graphicsItemRect.height() / (2 * distance));
    }
    else
    {
        distance = innerRadius() + maxWidth / 2 + graphicsItemRect.width() / 2;
        angle = rotationAngle
                - (180 / M_PI)
                * qAtan(graphicsItemRect.height() / (2 * distance));

        rotationAngle -= 180;
    }

    gi->setPos(distance * qCos((M_PI / 180) * angle),
               -distance * qSin((M_PI / 180) * angle));
    gi->setRotation(-rotationAngle); //minus - because this function rotates clockwise.

    gi->show();
    ///////////////////////////////////////////////////////////////////////////////////
}
开发者ID:mcdir,项目名称:sui,代码行数:76,代码来源:sunmenuIiemview.cpp


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