reinterpret_cast casts away qualifiers
As Nick Strupat stated in comment,
reinterpret_cast can't cast away cv-qualifiers
So you can use reinterpret_cast
and const_cast
together.
Dialog *dialog = const_cast<Dialog*>(reinterpret_cast<const Dialog *>(data));
You need to also use a const_cast
to remove const
qualifiers. Also, casting from void *
can use static_cast
, it does not need to reinterpret. For example:
Dialog const *dialog = static_cast<Dialog const *>(data);
Dialog *d2 = const_cast<Dialog *>(dialog);
However , make sure that the Dialog is actually not a const
object; attempting to modify a const object (presumably setValue
does this) causes undefined behaviour.
I'd suggest rethinking the interface to ProgressBar
to avoid needing this cast.