| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 4 | |
Hi,
Just a simple question. I wanted to do this:
connect ( surfEdgeColorBt, SIGNAL ( clicked() ),
this, SLOT ( setColor(FOREGROUNDCOLOR,SURFMESHVIEW) );
with EDGECOLOR, SURFMESHVIEW being defined as constants.
But I get a error message saying :
Object::connect: No such slot
CSBDMainWindow::setColor(FOREGROUNDCOLOR,SURFMESHVIEW)
even though I have a function declared as a slot void setColor(int
value1, int value2);
Is there a way to connect my signal to this function with arguments
directly?
Thanks,
Marie
--
[ signature omitted ]
> > Is there a way to connect my signal to this function with arguments > directly? > > No, args in SLOT func must match or less than args in SIGNAL func. Lingfa -- [ signature omitted ]
With a minor change you can make this work... In the classes definition of the method set color Change setColor( int, int ) to setColor( int value1=FOREGROUNDCOLOR, int value2=SURFMESHVIEW ) And then in your connect, call SLOT( setColor( int, int ) ) Works like a charm Another method, have 2 slots, one with parameters one without, and have the one without call the one with default parameters.. But I find that very un-C++ Scott > -----Original Message----- > From: Marie-Christine Vallet [mailto:mmvallet@xxxxxxxxxxx] > Sent: Friday, October 19, 2007 1:40 PM > To: qt-interest@xxxxxxxxxxxxx > Subject: Signals and slots > > Hi, > Just a simple question. I wanted to do this: > > connect ( surfEdgeColorBt, SIGNAL ( clicked() ), > this, SLOT ( setColor(FOREGROUNDCOLOR,SURFMESHVIEW) ); > > with EDGECOLOR, SURFMESHVIEW being defined as constants. > > But I get a error message saying : > Object::connect: No such slot > CSBDMainWindow::setColor(FOREGROUNDCOLOR,SURFMESHVIEW) > > > even though I have a function declared as a slot void setColor(int > value1, int value2); > > Is there a way to connect my signal to this function with arguments > directly? > > Thanks, > Marie > > -- > 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 ]
Em Saturday 20 October 2007 00:06:26 Scott Aron Bloom escreveu: > Change setColor( int, int ) to setColor( int value1=FOREGROUNDCOLOR, int > value2=SURFMESHVIEW ) > > And then in your connect, call SLOT( setColor( int, int ) ) You have to name it SLOT(setColor()) so that the default parameters apply. -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
> Em Saturday 20 October 2007 00:06:26 Scott Aron Bloom escreveu: > > Change setColor( int, int ) to setColor( int value1=FOREGROUNDCOLOR, int > > value2=SURFMESHVIEW ) > > > > And then in your connect, call SLOT( setColor( int, int ) ) > > You have to name it SLOT(setColor()) so that the default parameters apply. Ill defer to your recommendation, but I have never done that... And when I have, I get the warning "no slot exists" since the definition of the slot has the int,int parameters.... Scott -- [ signature omitted ]
Em Monday 22 October 2007 16:44:49 Scott Aron Bloom escreveu: > > Em Saturday 20 October 2007 00:06:26 Scott Aron Bloom escreveu: > > > Change setColor( int, int ) to setColor( int value1=FOREGROUNDCOLOR, > > int > > > > value2=SURFMESHVIEW ) > > > > > > And then in your connect, call SLOT( setColor( int, int ) ) > > > > You have to name it SLOT(setColor()) so that the default parameters > > apply. > > Ill defer to your recommendation, but I have never done that... And when > I have, I get the warning "no slot exists" since the definition of the > slot has the int,int parameters.... If you declare the slot like this in your class: public slots: void setColor(int foreground = -1, int background = -1); the moc will generate three slots: void setColor() void setColor(int) void setColor(int, int) The former two have a special attribute "cloned" set on them, if you inspect via QMetaMethod. -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
> void setColor() > void setColor(int) > void setColor(int, int) > The former two have a special attribute "cloned" set on them, if you > inspect > via QMetaMethod. Thanks for the info... I guess its been a while since I have used that and inspected it... Scott -- [ signature omitted ]