Help Newbie Subclass QStringList
My first post here!
I am a newbie to Qt and quite newbie to C++. What I am trying to do is to subclass QStringList, but I don't make it. This is what I have tried out so far:
Code:
{
Q_OBJECT
public:
MyStringList();
protected:
int numbers_pos[100];
public Q_SLOTS:
void set_number(int pos, int line_number);
int get_number(int pos);
};
I'm getting errors that:
Code:
error: invalid static_cast from type 'QObject*' to type 'MyStringList*'
and I am quite sure that it has to do with the Q_OBJECT macro. However, it does not let me remove it.
Any guesses?
Thanks a lot !
Re: Help Newbie Subclass QStringList
QStringList is not a subclass of QObject. Its subclasses cannot have signals or slots unless you inherit them from QObject as well. However it is very unusual to subclass both QObject and QStringList. It's more likely you should subclass QObject and equip it with a QStringList property instead.