本文整理汇总了C++中QQuickItem::setZ方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickItem::setZ方法的具体用法?C++ QQuickItem::setZ怎么用?C++ QQuickItem::setZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickItem
的用法示例。
在下文中一共展示了QQuickItem::setZ方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QQmlComponent
QQuickItem * DataSetView::createRowNumber(int row)
{
//std::cout << "createRowNumber("<<row<<") called!\n" << std::flush;
if(_rowNumberDelegate == NULL)
{
_rowNumberDelegate = new QQmlComponent(qmlEngine(this));
_rowNumberDelegate->setData("import QtQuick 2.10\nItem {\n"
"property alias text: tekst.text\n"
"Rectangle { color: \"lightGrey\"; anchors.fill: parent }\n"
"Text { id: tekst; anchors.centerIn: parent }\n"
"}", QUrl());
}
QQuickItem * rowNumber = NULL;
if(_rowNumberItems.count(row) == 0 || _rowNumberItems[row] == NULL)
{
if(_rowNumberStorage.size() > 0)
{
#ifdef DEBUG_VIEWPORT
std::cout << "createRowNumber("<<row<<") from storage!\n" << std::flush;
#endif
rowNumber = _rowNumberStorage.top();
_rowNumberStorage.pop();
}
else
{
#ifdef DEBUG_VIEWPORT
std::cout << "createRowNumber("<<row<<") ex nihilo!\n" << std::flush;
#endif
rowNumber = qobject_cast<QQuickItem*>(_rowNumberDelegate->create());
rowNumber->setParent(this);
rowNumber->setParentItem(this);
}
rowNumber->setProperty("z", 10);
rowNumber->setProperty("text", QString::fromStdString(std::to_string(row + 1))); //Nobody wants zero-based rows...
rowNumber->setY(_dataRowsMaxHeight * (1 + row));
rowNumber->setZ(-3);
rowNumber->setHeight(_dataRowsMaxHeight);
rowNumber->setWidth(_rowNumberMaxWidth);
rowNumber->setVisible(true);
_rowNumberItems[row] = rowNumber;
}
else
rowNumber = _rowNumberItems[row];
rowNumber->setX(_viewportX);
return _rowNumberItems[row];
}
示例2: ind
QQuickItem * DataSetView::createTextItem(int row, int col)
{
//std::cout << "createTextItem("<<row<<", "<<col<<") called!\n" << std::flush;
if((_cellTextItems.count(col) == 0 && _cellTextItems[col].count(row) == 0) || _cellTextItems[col][row] == NULL)
{
if(_itemDelegate == NULL)
{
_itemDelegate = new QQmlComponent(qmlEngine(this));
_itemDelegate->setData("import QtQuick 2.10\nText { property bool active: true; text: \"???\"; color: active ? 'black' : 'grey' }", QUrl());
}
QQuickItem * textItem = NULL;
if(_textItemStorage.size() > 0)
{
#ifdef DEBUG_VIEWPORT
std::cout << "createTextItem("<<row<<", "<<col<<") from storage!\n" << std::flush;
#endif
textItem = _textItemStorage.top();
_textItemStorage.pop();
}
else
{
#ifdef DEBUG_VIEWPORT
std::cout << "createTextItem("<<row<<", "<<col<<") ex nihilo!\n" << std::flush;
#endif
textItem = qobject_cast<QQuickItem*>(_itemDelegate->create());
textItem->setParent(this);
textItem->setParentItem(this);
}
QModelIndex ind(_model->index(row, col));
bool active = _model->data(ind, _roleNameToRole["active"]).toBool();
textItem->setProperty("color", active ? "black" : "grey");
textItem->setProperty("text", _model->data(ind));
textItem->setX(_colXPositions[col] + _itemHorizontalPadding);
textItem->setY(-2 + _dataRowsMaxHeight + _itemVerticalPadding + row * _dataRowsMaxHeight);
textItem->setZ(-4);
textItem->setVisible(true);
_cellTextItems[col][row] = textItem;
}
return _cellTextItems[col][row];
}