punkypogo
30th July 2010, 08:56
Hi,
I made a Qt singleton class:
// decl
class QFoo : QObject
{
Q_OBJECT
public:
static QFoo* getInstance( QObject* parent=0 );
static void destroy();
signal:
void fooSignal();
private:
static QFoo* p_instance;
QFoo( QObject* parent );
~QFoo();
};
// impl
QFoo* QFoo::p_instance = 0;
QFoo* QFoo::getInstance( QObject* parent )
{
if( !p_instance )
p_instance = new QFoo( parent );
return p_instance;
}
void QFoo::destroy()
{
if( p_instance )
delete p_instance;
}
QFoo::QFoo( QObject* parent ) : QObject( parent )
{
}
QFoo::~QFoo()
{
}
I want to connect its fooSignal() to a slot:
QFoo* pFoo = QFoo::getInstance();
connect( pFoo, SIGNAL( fooSignal() ), this, SLOT( aSlot() ) );
My problem is that I get compiler error with the connect:
"error C2243: 'type cast'*: conversion from 'QFoo *' to 'const QObject *' exists, but is not accessible"
Do you have any idea?
Thanks in advance.
I made a Qt singleton class:
// decl
class QFoo : QObject
{
Q_OBJECT
public:
static QFoo* getInstance( QObject* parent=0 );
static void destroy();
signal:
void fooSignal();
private:
static QFoo* p_instance;
QFoo( QObject* parent );
~QFoo();
};
// impl
QFoo* QFoo::p_instance = 0;
QFoo* QFoo::getInstance( QObject* parent )
{
if( !p_instance )
p_instance = new QFoo( parent );
return p_instance;
}
void QFoo::destroy()
{
if( p_instance )
delete p_instance;
}
QFoo::QFoo( QObject* parent ) : QObject( parent )
{
}
QFoo::~QFoo()
{
}
I want to connect its fooSignal() to a slot:
QFoo* pFoo = QFoo::getInstance();
connect( pFoo, SIGNAL( fooSignal() ), this, SLOT( aSlot() ) );
My problem is that I get compiler error with the connect:
"error C2243: 'type cast'*: conversion from 'QFoo *' to 'const QObject *' exists, but is not accessible"
Do you have any idea?
Thanks in advance.