|
|
newbie:QT3.0 QObject::connect fails (Suse8.2)
Hi NG,
under what circumstances could the connect call fail, Trolltech sais:
"The function returns TRUE if it successfully connects the signal to the
slot. It will return FALSE if it cannot create the connection, for example,
if QObject is unable to verify the existence of either signal or member, or
if their signatures aren't compatible."
But when is Qobject unable to verify the existence of signal/member and what
means incompatible signatures?
I'm trying to read from a socket using QSocketNotifier, in a way like this:
class foo
{
public:
foo(QObject * parent, const char * name )
{
...
socketfd = getFileDescriptor();
sn = new QSocketNotifier(socketfd,QSocketNotifier::Read,parent,name);
connect(sn,SIGNAL(activated(int)),SLOT(ReadData()));
...
};
private:
QSocketNotfier *sn;
private slots:
void ReadData()
{
...
};
};
But all I get is an error message:
QObject::connect: No such slot foo::ReadData()
QObject::connect: (sender name: 'unnamed')
QObject::connect: (receiver name: 'unnamed')
Any ideas?
Thanx
Andreas
|
|
0
|
|
|
|
Reply
|
mikl0012 (2)
|
10/5/2004 5:10:31 PM |
|
Andreas wrote:
> Hi NG,
>
> under what circumstances could the connect call fail, Trolltech sais:
> "The function returns TRUE if it successfully connects the signal to the
> slot. It will return FALSE if it cannot create the connection, for example,
> if QObject is unable to verify the existence of either signal or member, or
> if their signatures aren't compatible."
>
> But when is Qobject unable to verify the existence of signal/member and what
> means incompatible signatures?
"Compatible signatures" means, that the slot accepts variables of the same type,
as the signal emits
>
> I'm trying to read from a socket using QSocketNotifier, in a way like this:
>
> class foo
> {
Uh, oh, lots of bad things. First, you connect a signal that emits an "int" to a
slot that accepts nothing -->incompatible signatures. Second, all objects with
signals/slots must have the Q_OBJECT macro and be directly or indirectly derived
from QObject. Third, you must run the moc and include its output into your
program (perhaps that one you got right by using qmake. You should really step
through one of the tutorials to get those basics right.
> Thanx
> Andreas
|
|
0
|
|
|
|
Reply
|
auriocus (80)
|
10/8/2004 10:23:39 PM
|
|
|
1 Replies
24 Views
(page loaded in 0.063 seconds)
|
|
|
|
|
|
|
|
|