Question

I am quite new to Qt. Let MyClass be a sub-class of QObject.

Is there a way to convert properly a const MyClass * object to a MyClass * object?

I wanted to create a constructor MyClass(const MyClass *object); but it doesn't seem to be recommended.

Was it helpful?

Solution

Use the following code :

 MyClass *objRef = const_cast<MyClass *>(obj);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top