Solved Type casting in Qt
What is a better way to do typecasting in Qt
I'm getting warning saying "
use of old-style cast" by typecasting following way:
What is the better way to do this?
Thanks in advance.
JonB last edited by JonB
You're "not allowed" to use those (lovely) C-style casts any longer. This isn't really Qt, it's C++. You should Google for generic
dynamic_cast<>for use in C++ code (e.g. https://en.cppreference.com/w/cpp/language/static_cast), and for
qobject_cast<>in the Qt docs for a specific one useful in some Qt circumstances.
I believe the compiler will be happier with your code if you try:
or probably better If it's OK with the type coercing:
Thanks a lot for the feedback :)
so is your problem solved? Then pleas mark this topic as SOLVED too. Thanks!