所以我想在C ++ Qt中创建一个template
类。问题是我在这个课程中使用signals
/ slots
。
我的班级标题看起来像
template <class T>
class Container : public QObject
{
Q_OBJECT
protected:
QVector<T*> vec;
public:
Container();
~Container(void);
int getSize() const;
T * operator[] (int);
T * operator() (int);
void operator <<(T*);
void operator >>(T*);
bool exists(T*);
signals:
void updateTable();
void updateTable(int,int);
void sizeSignal(int);
public slots:
void insert(T*);
void insert(int, T*);
void edit(QTableWidgetItem*);
void remove(int);
};
如何让它发挥作用?
尝试过这样的事情:
template <class T>
class Container : public ContainerSignalsSlots
{
public:
Container();
~Container(void);
int getSize() const;
T * operator[] (int);
T * operator() (int);
void operator <<(T*);
void operator >>(T*);
bool exists(T*);
};
class ContainerSignalsSlots : public QObject
{
Q_OBJECT
protected:
QVector<T*> vec;
signals:
void updateTable();
void updateTable(int,int);
void sizeSignal(int);
public slots:
void insert(Class1*);
void insert(int, Class1*);
void insert(Class2*);
void insert(int, Class2*);
void edit(QTableWidgetItem*);
void remove(int);
};
但是我应该如何处理QVector
?