Important: Please read the Qt Code of Conduct -

[SOLVED] QGraphicsItem::ItemSelectedChange or QGraphicsItem::ItemSelectedHasChanged?

  • Greetings.

    I'm reimplementing the virtual function QGraphicsItem::ItemChange() to make my custom QGraphicsItem (QGraphicsItem subclass), change its color when the item is selected and/or released.

    My question is with which value of the enumerated type GraphicsItemChange, I must compare the parameter "change": QGraphicsItem::ItemSelectedChange or QGraphicsItem::ItemSelectedHasChanged?

    Thanks in advance for any help and/or suggestions.

  • Moderators

    Note the "Has" word in the enums. These two enums are sorta "I'm about to be changed" and "I've been changed just now".

    Which one you use is up to you but I don't think in this particular case (color change) it matters. Both will do. Conceptually you would change the color after the change has occurred to avoid having two items have that color at the same time, but I don't think this would be noticeable for such a brief moment.

  • Thanks, I had tried both options and both options worked well, but was not sure which was the right choice. Here QGraphicsItem::ItemSelectedHasChanged

Log in to reply