Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, March 2008
Connecting a signal to a slot with different parameters.


Message 1 in thread

When defining a connection you only put in the parameter types for the 
Signal and the Slots.

But is it possible to have a signal with one parameter call a slot with 
2 parameters?

For example in object B i have a SLOT setStuff(int i, QString value).

In object A i have Signal send(int i).

Is it possible, in any way, to connect A::send to B::setStuff?  Or is it 
only possible to connect signals and slots that have the exact same 
parameter list?

Thank you for any replies.

--
 [ signature omitted ] 

Message 2 in thread

In this case... just create the slot setStuff to have a default value
for value...

Ie 

Void setStuff( int i, QString value = QString() )

Scott

> -----Original Message-----
> From: Kevin [mailto:spifffers@xxxxxxxxxxx]
> Sent: Tuesday, March 18, 2008 2:23 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Connecting a signal to a slot with different parameters.
> 
> When defining a connection you only put in the parameter types for the
> Signal and the Slots.
> 
> But is it possible to have a signal with one parameter call a slot
with
> 2 parameters?
> 
> For example in object B i have a SLOT setStuff(int i, QString value).
> 
> In object A i have Signal send(int i).
> 
> Is it possible, in any way, to connect A::send to B::setStuff?  Or is
> it
> only possible to connect signals and slots that have the exact same
> parameter list?
> 
> Thank you for any replies.
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 3 in thread

Thanks for the replies.  Stupid question.  I thought i had tested with a 
default parameter value and couldn't get it to work.  Turns out i didn't 
actually test that.

Thank you all.

Scott Aron Bloom wrote:
> In this case... just create the slot setStuff to have a default value
> for value...
> 
> Ie 
> 
> Void setStuff( int i, QString value = QString() )
> 
> Scott
> 
>> -----Original Message-----
>> From: Kevin [mailto:spifffers@xxxxxxxxxxx]
>> Sent: Tuesday, March 18, 2008 2:23 PM
>> To: qt-interest@xxxxxxxxxxxxx
>> Subject: Connecting a signal to a slot with different parameters.
>>
>> When defining a connection you only put in the parameter types for the
>> Signal and the Slots.
>>
>> But is it possible to have a signal with one parameter call a slot
> with
>> 2 parameters?
>>
>> For example in object B i have a SLOT setStuff(int i, QString value).
>>
>> In object A i have Signal send(int i).
>>
>> Is it possible, in any way, to connect A::send to B::setStuff?  Or is
>> it
>> only possible to connect signals and slots that have the exact same
>> parameter list?
>>
>> Thank you for any replies.
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 4 in thread

On Tuesday 18 March 2008 22:22:53 Kevin wrote:
> When defining a connection you only put in the parameter types for the
> Signal and the Slots.
>
> But is it possible to have a signal with one parameter call a slot with
> 2 parameters?
>
> For example in object B i have a SLOT setStuff(int i, QString value).
>
> In object A i have Signal send(int i).
>
> Is it possible, in any way, to connect A::send to B::setStuff?  Or is it
> only possible to connect signals and slots that have the exact same
> parameter list?
possible if you either  have a default value 
    setStuff(int i, QString value=QString("default")). 
or use Qxt::bind

-- 
 [ signature omitted ]