PDA

View Full Version : help!!!



Ricardo_arg
30th June 2009, 06:39
Hi, i am new in qt4, i am converting a program that i was develop a few timne ago, and i am having problem now when subclassing a class that a was develop before.
#include <QObject>
class a : public QObject
{
public:
a();
Q_OBJECT
QString get_b(){return b}:
private:
QString b;
}
now when i am tryng to use class a
//======================
include "a.h"
class b: public a
{
public:
b();
set_a();//error "b is private from this context"!!!!!!
private:
QList<a> list;//error in compiler
}
//===================================
a little help will awesome
thx!

nish
30th June 2009, 07:17
move the Q_OBJECT macro in the private section of the class a


class a :public QObject
{
Q_OBJECT
public:
...
..
}

dongli
30th June 2009, 08:25
I think Q_OBJECT should be in the private section of class a, as it says in Qt document:


The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system.