//! [1] void DiagramScene::setLineColor(const QColor &color) { myLineColor = color; if (isItemChange(Arrow::Type)) { Arrow *item = qgraphicsitem_cast<Arrow *>(selectedItems().first()); item->setColor(myLineColor); update(); } }
/*--------------------------------------------------------------------------------------------- * (function: setLineColor) *-------------------------------------------------------------------------------------------*/ void ExplorerScene::setLineColor(const QColor &color) { myLineColor = color; if (isItemChange(Wire::Type)) { Wire *item = qgraphicsitem_cast<Wire *>(selectedItems().first()); item->setColor(myLineColor); update(); } }
//! [4] void DiagramScene::setFont(const QFont &font) { myFont = font; if (isItemChange(DiagramTextItem::Type)) { QGraphicsTextItem *item = qgraphicsitem_cast<DiagramTextItem *>(selectedItems().first()); //At this point the selection can change so the first selected item might not be a DiagramTextItem if (item) item->setFont(myFont); } }
void DiagramScene::setFont(const QFont &font) { myFont = font; if (isItemChange(DiagramTextItem::Type)) { QGraphicsTextItem *item = qgraphicsitem_cast<DiagramTextItem *>(selectedItems().first()); if (item) item->setFont(myFont); } }