Connection signals/slots of a sublcass



  • I'm working on a project where there is this interface called "ColorChooser." It is an abstract baseclass, with a signal "colorChanged," that is used to notify that the color the user has entered into the widget has changed. For example, I have a few sublcasses called "RGBWheel," and "HSVWheel," that implement the interface.

    Now, for some reason when I connect the signals and slots like in the first block the slot isn't being picked up on the signal emission. Yet If I connect them like in the second block, the slot does pickup on the signal
    @
    // Doesn't work
    ColorChooser *cc = new RGBWheel(this);
    connect(cc, &ColorChooser::colorChanged, app, &App::onColorChanged);

    // But this does
    connect((RGBWheel *)cc, &RGBWheel::colorChanged, app, &App::onColorChanged);
    @

    Can someone explain to me what I might be doing wrong here where I can't use the first method? Or is it completely impossible to connect signals/slots in that manner?

    EDIT: fixed issue, see below.



  • My Bad,

    Accidentally redeclared in the "colorChanged," signal in the RGBWheel class delcration.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.