PDA

View Full Version : simple signals and slots



kroenecker
24th March 2007, 01:31
I can't get this to compile:



#include <QApplication>
#include <QObject>

#include "signal.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

MySignal a;
MySignal b;

int ret = app.exec();

return ret;
}




#include "signal.h"
#include <iostream>

MySignal::MySignal()
{}

MySignal::~MySignal()
{}




#ifndef MYSIGNAL_H
#define MYSIGNAL_H

#include <QObject>

class MySignal : public QObject
{

public:
MySignal();
virtual ~MySignal();

void setInt(int);

// signals:
// void send(int);

// public slots:
// void received(int);

private:
int value;

};

#endif



I keep getting this error:

./signal.h:6: error: invalid use of undefined type ‘struct QObject’
/usr/include/qt4/QtCore/qobjectdefs.h:164: error: forward declaration of ‘struct QObject’

kroenecker
24th March 2007, 01:41
This is almost too funny to be true since I've been struggling all day with QT; I think that declaring my files with the names signal.h and signal.cpp was causing the problem. I changed the names to mysignal.h and mysignal.cpp and now it compiles. There must have been some conflict there.

Brandybuck
24th March 2007, 05:15
I had the exact same problem yesterday morning. But the error messages were quite obscure, and it took me a couple of hours to discover the problem. :rolleyes: