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


C++ QQuickItem::y方法代码示例

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


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

示例1: drawCompressor

void DynamicController::drawCompressor(QSGNode * rootNode) {
    //Update knobs
    if (!this->simple()) {
        QObject * threshKnob = knobs[0];
        QObject * ratKnob = knobs[1];

        threshKnob->setProperty("x", graphToNodeX(_tempModel["compx"]));
        threshKnob->setProperty("y", graphToNodeY(_tempModel["compy"]));

        ratKnob->setProperty("x", graphToNodeX(yAxis.max));
        ratKnob->setProperty("y", graphToNodeY(_tempModel["compy"]) * (1 - _tempModel["ratio"]));
    }

    QSGGeometryNode * lineNode = new QSGGeometryNode();
    QSGGeometry * lineGeom = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), (3));

    QSGFlatColorMaterial *material = new QSGFlatColorMaterial;

    material->setColor(this->curveColor());
    material->setFlag(QSGMaterial::Blending);

    lineNode->setMaterial(material);
    lineNode->setFlag(QSGNode::OwnsGeometry);
    lineNode->setFlag(QSGNode::OwnedByParent);
    lineNode->setFlag(QSGNode::OwnsMaterial);

    lineGeom->setDrawingMode(GL_LINE_STRIP);
    glLineWidth(2.0f);

    QSGGeometry::Point2D* points = lineGeom->vertexDataAsPoint2D();

    QRectF bounds = boundingRect();

    points->set(bounds.left(), bounds.bottom()); points++;

    for (int i = 0; i < 2; i++) {
        QQuickItem * q = qobject_cast<QQuickItem*>(knobs[i]);
        points->set(q->x(), q->y());
        points++;
    }

    lineNode->setGeometry(lineGeom);
    rootNode->appendChildNode(lineNode);
}
开发者ID:youdonotexist,项目名称:Harman-Intl.-Prototypes,代码行数:44,代码来源:dyncontroller.cpp

示例2: traverseObject

/*!
  Traverse QObject based items.
*/
void SceneGraphTraverse::traverseObject(TasObject* objectInfo, QObject* object, TasCommand* command)
{
    Q_UNUSED(command);

    QQuickItem* item = qobject_cast<QQuickItem*>(object);

    if (item) {
        QQmlContext* context = QQmlEngine::contextForObject(object);

        if (context) {
            QString name = context->nameForObject(object);
            objectInfo->addAttribute("QML_ID", name);
        }

#ifdef USE_QTQML_PRIVATE_HEADERS
        addTypeInfo(item, objectInfo);
#endif

        mTraverseUtils->addObjectDetails(objectInfo, object);

        objectInfo->addAttribute("objectType", TYPE_QSCENEGRAPH);

        QPointF point = item->mapToScene(QPoint());

        // needed for visualizer
        objectInfo->addAttribute("x", (int)point.x());
        objectInfo->addAttribute("y", (int)point.y());
        objectInfo->addAttribute("x_absolute", (int)point.x());
        objectInfo->addAttribute("y_absolute", (int)point.y());


        objectInfo->addAttribute("x_relative", item->x());
        objectInfo->addAttribute("y_relative", item->y());

        // TODO already included?
        objectInfo->addAttribute("width", item->width());
        objectInfo->addAttribute("height", item->height());
    }
}
开发者ID:alirezaarmn,项目名称:cutedriver-agent_qt,代码行数:42,代码来源:scenegraphtraverse.cpp

示例3: layoutChildrenWithDefaultSize

void StretchColumn::layoutChildrenWithDefaultSize() {
	//static int count = 0;
	//qDebug() << "Column Default Size" << ++count;
    Q_ASSERT(m_defaultSize != 0);

	const QList<QQuickItem *> childrenList = childItems();
	if (childrenList.isEmpty()) return;

    const int contentWidth = width() - m_leftMargin - m_rightMargin;
    qreal currY = 0;
    for (QList<QQuickItem *>::const_iterator it = childrenList.constBegin(); it != childrenList.constEnd(); ++it) {
		QQuickItem* child = (*it);
		if (child == Q_NULLPTR || !child->isVisible()) {
			continue;
		}

		// add spacing if it is not the first item:
		if (currY > 0) {
			currY += m_spacing;
		}
		if (currY != child->y()) child->setY(currY);
		// check if item has a stretch proportion set:
		if (child->implicitHeight() < 0) {
			// yes -> set it to default size multiplied by relative size:
            qreal newHeight = m_defaultSize * child->implicitHeight() * -1;
            if (newHeight != child->height()) child->setHeight(newHeight);
		}
		// set width of all items to fill the layout:
        if (m_leftMargin != child->x()) child->setX(m_leftMargin);
		if (contentWidth != child->width()) child->setWidth(contentWidth);
		currY += child->height();
	}

	// set implicit size to fit all items:
	if (currY != implicitHeight()) setImplicitHeight(currY);
}
开发者ID:ElectronicTheatreControlsLabs,项目名称:LuminosusEosEdition,代码行数:36,代码来源:StretchLayouts.cpp

示例4: layoutChildrenWithProportions

void StretchColumn::layoutChildrenWithProportions() {
	//static int count = 0;
	//qDebug() << "Column Proportions" << ++count;
	const QList<QQuickItem*> childrenList = childItems();
	if (childrenList.isEmpty()) return;
	if (height() <= 0) return;
	int visibleItems = 0;
    qreal availableForStretch = height();
	qreal sumStretchProportions = 0.0;

	// iterate over all children and calculate available size to stretch items:
    for (QList<QQuickItem *>::const_iterator it = childrenList.constBegin(); it != childrenList.constEnd(); ++it) {
		QQuickItem* child = (*it);
		if (child == Q_NULLPTR || !child->isVisible()) {
			continue;
		}

		if (child->implicitHeight() >= 0) {
			// no stretch proportion set -> leave size and remove it from available space:
			availableForStretch -= child->height();
		} else {
			// a stretch proportion is set -> add it to sum:
			sumStretchProportions += (child->implicitHeight() * -1);
		}
		visibleItems++;
	}
	// remove spacing from available space:
	availableForStretch -= m_spacing * (visibleItems - 1);

    const int contentWidth = width() - m_leftMargin - m_rightMargin;
    QPointer<QQuickItem> lastStretchItem = nullptr;
    qreal currY = 0;
    for (QList<QQuickItem *>::const_iterator it = childrenList.constBegin(); it != childrenList.constEnd(); ++it) {
		QQuickItem* child = (*it);
		if (child == Q_NULLPTR || !child->isVisible()) {
			continue;
		}

		// add spacing if it is not the first item:
		if (currY > 0) {
			currY += m_spacing;
		}
        if (currY != child->y()) child->setY(currY);
		// check if item has a stretch proportion set (if not do nothing):
		if (child->implicitHeight() < 0) {
			// get the stretch proportion:
			qreal stretchProportion = (child->implicitHeight() * -1);
			// calculate the relation of the total space available for stretched items
			// that this item will use:
			// (sumStretchProportion can not be 0 (in divison) because if this "if" is executed,
			// there has been at least one item with a stretch proportion set)
			qreal relationOfSpaceAvailableForStretch = stretchProportion / sumStretchProportions;
            qreal newHeight = qRound(availableForStretch * relationOfSpaceAvailableForStretch);
            if (newHeight != child->height()) child->setHeight(newHeight);
			lastStretchItem = child;
		}
		// set width of all items to fill the layout:
        if (m_leftMargin != child->x()) child->setX(m_leftMargin);
        if (contentWidth != child->width()) child->setWidth(contentWidth);
		currY += child->height();
	}

	// check if last item fills whole remaining space in this layout:
	// (can happen because of rounding mistakes)
	if (lastStretchItem) {
		double pxMissing = height() - currY;
        if (pxMissing > 0.0001) {
            // qInfo() << "StretchColumn layout mismatch: " << pxMissing;
			// it does not -> adjust it:
			lastStretchItem->setHeight(lastStretchItem->height() + pxMissing);
		}
	}
}
开发者ID:ElectronicTheatreControlsLabs,项目名称:LuminosusEosEdition,代码行数:73,代码来源:StretchLayouts.cpp


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