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

Qt-interest Archive, April 2008
Signals doesn't get inherited?


Message 1 in thread

Hi again,

As I'm still new with Qt development, I get a couple of surprises.
Here's one of them...
///////
class A : QObject {
public:
 A() { }
signal:
  sSomethingHappend();
}

class B : public A {
public:
  B : A() { }

}
///////

//somewhere else
B bObj;
connect( bObj , SIGNAL( sSomethingHappend() ) ,  someListener,
SLOT(doSomething()) );
///////

...after a successful moc (no msgs) I got this console message when
running the binary

Object::connect: No such signal B::sSomethingHappend(void)  ....

Is it suppose to be like this? Or am doing something wrong somewhere.
Intuitively I figured that signals is implemented as public (or
atleast protected)
member function so should be inherited by subclasses.

Thanks before.

-- 
 [ signature omitted ] 

Message 2 in thread

Am Donnerstag, 3. April 2008 schrieb Barkah Yusuf Widodo:
> As I'm still new with Qt development, I get a couple of surprises.
> Here's one of them...
> ///////
> class A : QObject {

Add a "Q_OBJECT" here and your signal will probably work.

> public:
>  A() { }
> signal:
>   sSomethingHappend();
> }
> class B : public A {

Here probably too. At least it won't hurt...

> public:
>   B : A() { }
> }
> ///////
> //somewhere else
> B bObj;
> connect( bObj , SIGNAL( sSomethingHappend() ) ,  someListener,
> SLOT(doSomething()) );
> ///////
> ...after a successful moc (no msgs) I got this console message when
> running the binary
> Object::connect: No such signal B::sSomethingHappend(void)  ....

Arnold
-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.