Hi.
I'm trying to change the brush on an QGraphicsItem (More precise my own class that inherits from QGraphicsPolygonItem).
My reimplementation of mousePressEvent looks like this
Qt Code:
{ std::cout << "label: " << _label->label << endl; if (!_label->label.compare("a")) { QBrush brush; brush.setColor(color); setBrush(brush); _label->label = "b"; this->setZValue(parentItem()->zValue() + 1); } else if (!_label->label.compare("b")) { QBrush brush; brush.setColor(color); setBrush(brush); _label->label = "a"; this->setZValue(parentItem()->zValue() + 1); } update(boundingRect()); event->ignore(); }To copy to clipboard, switch view to plain text mode
I can see that each time I press the mouse button on an item the label toggles between 'a' and 'b'. My items originally have a brush with a blue color therefore they are initially painted with a blue interior, but when I click on them not only does the color not change to the one specified in the if statements, the original blue color disappears and the background (the parent item) gets visible.
Can someone see what I'm doing wrong?
Any help will greatly appreciated
Regards,
Thomas
Bookmarks