 Now we're going to take a look at something called QObjectCast and QObjectCast is a little bit different. It's specific to Q. It's not built into C++ itself and It does not use the C++ RTTI or runtime type information It only uses QObjects, meaning it backbones on QObjects and the Qt meta object system All right, so let's go ahead and add existing files And we're going to just repurpose the same classes that we've been working with and we're going to make another class here We're going to add new and we're going to add a C++ class. I want to call it dog We are not going to make a base class here. We're just going to simply click next So when we look at dog as soon as it pops up in here You can see this is not a Qt object. So if we look at car, it's got the Q object It's inheriting QObject dog. It does not have any of that dog. It's just a plain old C++ class here No, Qt goodness baked in how sad. All right, so let's flip over to our main I'm going to include our headers here there we go and Let's just do a drive to base We're gonna say race car pointer player 1 Equal new race car and then we're going to just say car pointer My car equals and we're going to do the Q object cast and we want a pointer to a car And you guessed it. We're gonna convert player 1 So drive to base. Let's test this out. So we're currently driving. So it successfully Converted that from a race car to a car You think about that what it what it's actually done is quite complex under the hood It's stripped out and ignored all the C++ runtime type information And it's using just the Q object information to determine whether or not that's a valid cast That's pretty cool But we can also do the base to derived and let's test that out. So we'll say race car pointer to fast car Equals Q object cast And this time we want to get a race car and we're gonna convert my car because my car is just a normal car Not a race car as much as I'd like it to be sometimes So now we've got this pointer to a fast car So fast car and we can actually go fast Think about what we just did here We basically just ignored the four previous tutorials and we just said use Q object cast But I wanted to demonstrate all that so you really understood Q object cast and what it's doing Let's make sure we can actually use this as a race car and sure enough zoom just works If you're an old-school C++ programmer, you are gonna absolutely fall in love with Q object cast because of just how powerful it is However, there is one drawback will not use Non-Qt objects and that's why we made the dog class. We're gonna say whoops dog pointer to We'll call this Fido equal Q object cast And we want a dog out of this thing whoops Let's try just converting our fast car here and see what happens notice how It doesn't actually give us any sort of indication that something's going on It's just saying we have an unused variable we can get rid of that by using the Q and Q unused Macro here and let's say Fido So just staring at our screen here, it thinks everything's gonna work But if we go ahead and try and run this but we have a problem Q metacall is not member of dog and we get this kind of nasty little Size of Q metacall size of in blah blah blah. What's really going on here is that we cannot use this with non-Qt objects And you can see right here static assertion has failed Requires type to have Q object macro, which of course is This guy right here, which our dog does not have So we've covered a lot of conversion which one should you actually use? Well when in doubt I would say without a doubt When in doubt without a doubt That made a lot of sense. Anyways, when it out without a doubt use Q object cast Why because you can go from the base of the drive You can go to the drive to the base and back and forth and as long as you're using Q objects Everything just works the only time you're really really gonna get in trouble is if you try to use a non-Qt object I hope you enjoyed the video you just watched that was a preview of one of the videos out in the Qt core for beginners with C++ course I have out on Udemy I am going to be making an intermediate in advance and then we're gonna start working on GUI technologies For example showing buttons lists tree views you name it and then moving on to things like QML The reason why I've restarted this whole thing is if you're watching these videos out on YouTube They are a little old this one was done in 2011 and the technologies changed over time So because the technology has changed some of these videos as good as they are Really don't line up with the current Q technology stack anymore. So I wanted to start from scratch I hope to see you out on Udemy and also in the voidrums Facebook group. See you there