[Qt-interest] problem with signal/slot
Andre Somers
andre at familiesomers.nl
Tue Dec 21 13:59:56 CET 2010
Op Di, 21 december, 2010 1:47 pm, schreef prashant bhutani:
>> > this is my code :
>> >
>> > class CustomScene : public QGraphicsScene
>> > {
>> >
>> > Q_OBJECT
>> > public:
>> > CustomScene()
>> > {
>> > alphaSlider = new QSlider(Qt::Horizontal);
>> > alphaSlider->setTickInterval(1);
>> > alphaSlider->setRange(0,255);
>> > alphaSlider->setMinimumSize(105,20);
>> > alphaSlider->move(6,222);
>> > alphaSlider->setToolTip("Opacity");
>> > connect( alphaSlider, SIGNAL(valueChanged(int)),
>> > SLOT(updateAlphaValue()) );
>>
> Sorry but shouldn't this connect method refer to second object?
> like connect(&obj1, signal, &obj2, slot)
No, that is not really needed. There are overloaded versions of connect.
If you ommit the second object reference, it will refer to this.
These two statements are equivalent:
connect(obj1Ptr, SIGNAL(theSignal()), this, SLOT(theSlot()));
connect(obj1Ptr, SIGNAL(theSignal()), SLOT(theSlot()));
André
More information about the Qt-interest-old
mailing list