I'm pretty sure that I'm missing something fairly basic here, but I can't figure this out and it's driving me crazy:
How do I return a pointer to an instance of a class derived from Slider with Slider::Listener?
I have a class that inherits Slider, called DerivedSlider. In my main component, I inherit from Slider::Listener and override sliderValueChanged, which takes as argument a pointer to a Slider. I also create an instance of DerivedSlider, called derivedSlider. Here's what's confusing: When sliderValueChanged is called, I can compare the Slider pointer it receives as an argument to a reference to my derivedSlider, and it works just as I'd hope. However the Slider pointer then cannot be dereferenced to access members of the DerivedSlider object since it seems to point to the base part of my object.
How can it be that (slider == &derivedSlider) can be true, yet slider->derivedMethod() is illegal? Like I said, I think I'm missing something basic here but this is puzzling to me...
My first thought was to redefine the Listener class and related functions (addListener and removeListener) in my derived Class, but I can't seem to get it to work. I feel like I'm hitting a wall with the pimpl inside Slider.
Thanks in advance. Any ideas?