You will need to store a variable for color.
Say you have QColor m_color in your graphics item class.
Then in paint event you do the following -
Qt Code:
paint() { QColor color = m_color; color = m_color.dark(); painter->fillRect(boundingRect(),color); }To copy to clipboard, switch view to plain text mode
thats it, and now when you hover over the item, it will become dark.
Remember to set QGraphicsItem::setAcceptHoverEvents to true![]()




Reply With Quote
Bookmarks