Alex Rivera | Logout

Clean way to eliminate "unused parameter 'widget'" warning generated by QGraphicsItem::paint

Asked 2011-04-23T16:12:22.020
19

QGraphicsItem::paint has the following signature:

void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)

When I create custom QGraphicsItems, I have to provide an implementation for this function. The thing is... I never need to use the option and widget parameters, but I can't just remove them for obvious reasons. I always see these compiler warnings:

warning: unused parameter ‘widget’

warning: unused parameter ‘option’

Is there a proper to get rid of these warnings? I know I can hide them by mentioning the unused parameters in the function, but this is a very dirty solution and I'd like to know if there are better options.

Edit
Report

1 Answer

26

Don't provide parameter names to the unused parameters. For example (I'm not sure what your "event" refers to), to get rid of warning: unused parameter ‘option’, change your signature to:

void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* unused */, QWidget *widget)

(The /* unused */ tag is unnecessary as far as the warning goes, but it's useful for the human reader, I find.)

answered 2011-04-23T16:14:31.217

Your Answer