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

Qt-interest Archive, June 2007
QT4.3 slot with argument question


Message 1 in thread

Hi, Ive been reading thru the docs on signals and slots.
Im trying to do the following:

connect(m_actions[act_idx], SIGNAL(triggered()),
			this, SLOT(loadFile(act_idx)));

It appears that I cannot send 'act_idx' into 'loadFile()'
because triggered() takes no arguments.  I havent seen
how to get around this so far.  Im sure others have run
into this and have solved how to do it.

Can someone point me in the right direction or tell me
how to do it?

I appreciate it.
Thanks,
Jeff


--
 [ signature omitted ] 

Message 2 in thread

On 10.06.07 08:03:16, Jeff Lacki wrote:
> 
> Hi, Ive been reading thru the docs on signals and slots.
> Im trying to do the following:
> 
> connect(m_actions[act_idx], SIGNAL(triggered()),
> 			this, SLOT(loadFile(act_idx)));
> 
> It appears that I cannot send 'act_idx' into 'loadFile()'
> because triggered() takes no arguments.

Right.

> I havent seen
> how to get around this so far.  Im sure others have run
> into this and have solved how to do it.

See QSignalMapper for a solution to this problem.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

-----Original Message-----
From: Andreas Pakulat <apaku@xxxxxx>
Date: Sunday, Jun 10, 2007 8:14 am
Subject: Re: QT4.3 slot with argument question
To: qt-interest@xxxxxxxxxxxxx

On 10.06.07 08:03:16, Jeff Lacki wrote:
> 
> Hi, Ive been reading thru the docs on signals and slots.
> Im trying to do the following:
> 
> connect(m_actions[act_idx], SIGNAL(triggered()),
> 			this, SLOT(loadFile(act_idx)));
> 
> It appears that I cannot send 'act_idx' into 'loadFile()'
> because triggered() takes no arguments.
>
>Right.
>
>> I havent seen
> how to get around this so far.  Im sure others have run
> into this and have solved how to do it.
>
>See QSignalMapper for a solution to this problem.
>
>Andreas
>
you can also set the actions item data, and use sender() with a qobject cast to get the action back in the slot

Scott

--
 [ signature omitted ]