本文整理汇总了C++中parentItem函数的典型用法代码示例。如果您正苦于以下问题:C++ parentItem函数的具体用法?C++ parentItem怎么用?C++ parentItem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parentItem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transientParent
void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
{
QWindow *pw = transientParent();
if (!pw && parentItem())
pw = parentItem()->window();
if (!pw)
pw = this;
QRect g = pw->screen()->availableVirtualGeometry();
if (posx + w > g.right()) {
if (qobject_cast<QQuickMenuPopupWindow *>(transientParent())) {
// reposition submenu window on the parent menu's left side
int submenuOverlap = pw->x() + pw->width() - posx;
posx -= pw->width() + w - 2 * submenuOverlap;
} else {
posx = g.right() - w;
}
} else {
posx = qMax(posx, g.left());
}
posy = qBound(g.top(), posy, g.bottom() - h);
QQuickWindow::setGeometry(posx, posy, w, h);
}
示例2: parentItem
QVariant PixmapItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == ItemPositionChange)
{
// value is the new position.
QPointF newPos = value.toPointF();
QRectF rect = parentItem()->boundingRect();
rect.moveLeft(boundingRect().width()*3/4*-1);
rect.setWidth(rect.width() + boundingRect().width()*2/4 );
rect.moveTop(boundingRect().height()*3/4*-1);
rect.setHeight(rect.height() + boundingRect().height()*2/4 );
CardItem *card = qgraphicsitem_cast<CardItem *>(parentItem());
if (!rect.contains(newPos))
{
// Keep the item inside the scene rect.
int newX = (int)qMin(rect.right(), qMax(newPos.x(), rect.left()));
int newY = (int)qMin(rect.bottom(), qMax(newPos.y(), rect.top()));
if(card->isAlign())
{
int gridSize = card->getGridSize();
newX = (newX/(10*gridSize))*(10*gridSize);
newY = (newY/(10*gridSize))*(10*gridSize);
}
newPos.setX(newX);
newPos.setY(newY);
return newPos;
}
else
{
int newX = newPos.x();
int newY = newPos.y();
if(card->isAlign())
{
int gridSize = card->getGridSize();
newX = newPos.x()/(10*gridSize);
newX = newX * (10*gridSize);
newY = newPos.y()/(10*gridSize);
newY = newY*(10*gridSize);
}
newPos.setX(newX);
newPos.setY(newY);
return newPos;
}
}
return QGraphicsItem::itemChange(change, value);
}
示例3: toHtml
void ElementTitle::focusOutEvent(QFocusEvent *event)
{
QGraphicsTextItem::focusOutEvent(event);
QString htmlNormalizedText = toHtml().remove("\n", Qt::CaseInsensitive);
setTextInteractionFlags(Qt::NoTextInteraction);
parentItem()->setSelected(true);
// Clear selection
QTextCursor cursor = textCursor();
cursor.clearSelection();
setTextCursor(cursor);
unsetCursor();
if (mReadOnly)
return;
if (mOldText != toPlainText()) {
QString value = toPlainText();
if (mBinding == "name")
static_cast<NodeElement*>(parentItem())->setName(value);
else
static_cast<NodeElement*>(parentItem())->setLogicalProperty(mBinding, value);
}
setHtml(htmlNormalizedText);
}
示例4: Q_D
QRectF RadicalElectron::boundingRect() const {
if (!parentItem()) return QRectF();
Q_D(const RadicalElectron);
QRectF bounds(0,0,d->diameter,d->diameter);
bounds.translate(d->linker.getShift(parentItem()->boundingRect(), bounds));
return bounds;
}
示例5: qRound
Cell::CellState Cell::shrinkOrGrow()
{
int dishSize = qRound(parentItem()->boundingRect().width());
int neighbours = 0;
QListIterator<QGraphicsItem*> i(parentItem()->childItems());
while (i.hasNext()) {
QGraphicsItem *item = i.next();
if (item != this && collidesWithItem(item))
++neighbours;
}
if (!neighbours || m_size > dishSize / 3)
m_size *= randomReal(); // shrink - lonely or too big
else if (neighbours < 4) // grow - happy
m_size *= ((5 - neighbours) * randomReal());
else // shrink - too crowded
m_size *= ((1.0 / neighbours) + randomReal());
QPainterPath path;
qreal x = m_size * std::cos(AQP::radiansFromDegrees(1));
qreal y = m_size * std::sin(AQP::radiansFromDegrees(1));
path.moveTo(x, y);
for (int angle = 1; angle < 360; ++angle) {
qreal factor = m_size + ((m_size / 3) * (randomReal() - 0.5));
x = factor * std::cos(AQP::radiansFromDegrees(angle));
y = factor * std::sin(AQP::radiansFromDegrees(angle));
path.lineTo(x, y);
}
path.closeSubpath();
m_path = path;
prepareGeometryChange();
if (m_size < 5.0 && (qrand() % 20 == 0))
return Die; // small ones randomly die
return Live;
}
示例6: switch
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change)
{
case ItemPositionHasChanged:
if (parentItem() != 0)
{
if (parentItem()->type() == Graph::Type)
{
Graph * graph = qgraphicsitem_cast<Graph*>(parentItem());
Graph * tempGraph = graph;
graph = qgraphicsitem_cast<Graph*>(graph->getRootParent());
this->setParentItem(nullptr);
this->setParentItem(tempGraph);
}
if (verbose)
qDebug() << "node does not have a graph item parent";
}
foreach (Edge * edge, edgeList)
edge->adjust();
break;
case ItemRotationChange:
foreach (Edge * edge, edgeList)
edge->adjust();
break;
default:
break;
};
return QGraphicsItem::itemChange(change, value);
}
示例7: Q_Q
/*!
\internal
This function is called from subclasses to add a layout item \a layoutItem
to a layout.
It takes care of automatically reparenting graphics items, if needed.
If \a layoutItem is a is already in a layout, it will remove it from that layout.
*/
void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem)
{
Q_Q(QGraphicsLayout);
if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) {
if (maybeLayout->isLayout())
removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem);
}
layoutItem->setParentLayoutItem(q);
if (layoutItem->isLayout()) {
if (QGraphicsItem *parItem = parentItem()) {
static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem);
}
} else {
if (QGraphicsItem *item = layoutItem->graphicsItem()) {
QGraphicsItem *newParent = parentItem();
QGraphicsItem *oldParent = item->parentItem();
if (oldParent == newParent || !newParent)
return;
#ifdef QT_DEBUG
if (oldParent && item->isWidget()) {
QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item);
qWarning("QGraphicsLayout::addChildLayoutItem: %s \"%s\" in wrong parent; moved to correct parent",
w->metaObject()->className(), w->objectName().toLocal8Bit().constData());
}
#endif
item->setParentItem(newParent);
}
}
}
示例8: model
UIGChooserItemMachine::~UIGChooserItemMachine()
{
/* If that item is focused: */
if (model()->focusItem() == this)
{
/* Unset the focus: */
model()->setFocusItem(0);
}
/* If that item is in selection list: */
if (model()->currentItems().contains(this))
{
/* Remove item from the selection list: */
model()->removeFromCurrentItems(this);
}
/* If that item is in navigation list: */
if (model()->navigationList().contains(this))
{
/* Remove item from the navigation list: */
model()->removeFromNavigationList(this);
}
/* Remove item from the parent: */
AssertMsg(parentItem(), ("No parent set for machine-item!"));
parentItem()->removeItem(this);
}
示例9: QGraphicsPathItem
CanvasBezierLineMov::CanvasBezierLineMov(PortMode port_mode_, PortType port_type_, QGraphicsItem* parent) :
QGraphicsPathItem(parent, canvas.scene)
{
port_mode = port_mode_;
port_type = port_type_;
// Port position doesn't change while moving around line
item_x = parentItem()->scenePos().x();
item_y = parentItem()->scenePos().y();
item_width = ((CanvasPort*)parentItem())->getPortWidth(); // FIXME
QPen pen;
if (port_type == PORT_TYPE_AUDIO_JACK)
pen = QPen(canvas.theme->line_audio_jack, 2);
else if (port_type == PORT_TYPE_MIDI_JACK)
pen = QPen(canvas.theme->line_midi_jack, 2);
else if (port_type == PORT_TYPE_MIDI_A2J)
pen = QPen(canvas.theme->line_midi_a2j, 2);
else if (port_type == PORT_TYPE_MIDI_ALSA)
pen = QPen(canvas.theme->line_midi_alsa, 2);
QColor color(0,0,0,0);
setBrush(color);
setPen(pen);
update();
}
示例10: parentItem
void UIGChooserItem::updateGeometry()
{
/* Call to base-class: */
QIGraphicsWidget::updateGeometry();
/* Update parent's geometry: */
if (parentItem())
parentItem()->updateGeometry();
/* Special handling for root-items: */
if (isRoot())
{
/* Root-item should notify chooser-view if minimum-width-hint was changed: */
int iMinimumWidthHint = minimumWidthHint();
if (m_iPreviousMinimumWidthHint != iMinimumWidthHint)
{
/* Save new minimum-width-hint, notify listener: */
m_iPreviousMinimumWidthHint = iMinimumWidthHint;
emit sigMinimumWidthHintChanged(m_iPreviousMinimumWidthHint);
}
/* Root-item should notify chooser-view if minimum-height-hint was changed: */
int iMinimumHeightHint = minimumHeightHint();
if (m_iPreviousMinimumHeightHint != iMinimumHeightHint)
{
/* Save new minimum-height-hint, notify listener: */
m_iPreviousMinimumHeightHint = iMinimumHeightHint;
emit sigMinimumHeightHintChanged(m_iPreviousMinimumHeightHint);
}
}
}
示例11: setSystem
void QSGParticlePainter::componentComplete()
{
if (!m_system && qobject_cast<QSGParticleSystem*>(parentItem()))
setSystem(qobject_cast<QSGParticleSystem*>(parentItem()));
if (!m_system)
qWarning() << "ParticlePainter created without a particle system specified";//TODO: useful QML warnings, like line number?
QSGItem::componentComplete();
}
示例12: parentItem
QRectF HighlightItem::parentRect() const
{
if (parentItem())
return parentItem()->boundingRect();
else if (scene())
return scene()->sceneRect();
return QRectF(0, 0, 10, 10);
}
示例13: parentItem
void GEventNode::UpdateVerticalPosition()
{
// if their is a parent item, we draw the line within the pParentItem->boundingRect().
double heightLine = 11.4159;
if(parentItem())
heightLine = parentItem()->boundingRect().height();
setLine(0.0, 0.0, 0.0, heightLine);
}
示例14: clearItems
UIGSelectorItemGroup::~UIGSelectorItemGroup()
{
/* Delete all the items: */
clearItems();
/* Remove item from the parent: */
if (parentItem())
parentItem()->removeItem(this);
}
示例15: qDebug
bool Cell::isGrouped()
{
if(parentItem()) {
qDebug() << "isGrouped parent type:" << parentItem()->Type;
return true;
}
return false;
}