[Qt-interest] Encapsulates question.

phil prentice philp.cheer at talktalk.net
Thu Aug 12 15:17:49 CEST 2010


Hi
  Thankyou, Yes, of course!!! I've used signalmappers a lot in the past.
  I will change my code to use them.  
  So the general mechanism I'm using is good.
  Thankyou very much for that.

Phil

On Thursday 12 August 2010 12:50, Alessandro Portale wrote:
> On 8/12/2010 2:44 PM, ext phil prentice wrote:
> > I have a class that encapsulates an array of custom objects i.e.
> > class Fred
> > {
> >    ...
> >    private:
> >      Mike mike[6];	// Custom widgets.
>
> Instead of an array Mike[6] would use a QList<Mike*>. But that is
> probably just a matter of taste.
>
> > Now the index I wish to pass back is to identify which widget was
> > selected. How best to do this?
>
> That is exactly what QSignalMapper helps you with
>    http://doc.qt.nokia.com/4.6/qsignalmapper.html
>
> The documentation has an example, which I reformulate for Fred and Mike,
> below :)
>
> Let Fred have one QSignalMapper member. If Mike is derived from
> QPushButton, you connect the "SIGNAL(clicked())" of your Mikes to the
> "SLOT(map())" of the QSignalMapper. And for each Mike also call
> "QSignalMapper::setMapping()" with an individual int or QString.
> Then connect the "SIGNAL(mapped(int/QString))" to Fred's handling
> private slot.
>
> Hope that helps,
> Alessandro
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list