I m 粗略新到QT。 现在,我与我在一起一周。 我在试图把一种习俗数据类添加到像这样的清单中时,遇到了一个错误。
QObject parent;
QList<MyInt*> myintarray;
myintarray.append(new const MyInt(1,"intvar1",&parent));
myintarray.append(new const MyInt(2,"intvar2",&parent));
myintarray.append(new const MyInt(3,"intvar3",&parent));
我的门别类是一只简单的 wrap子,看像这样的东西。
#ifndef MYINT_H
#define MYINT_H
#include <QString>
#include <QObject>
class MyInt : public QObject
{
Q_OBJECT
public:
MyInt(const QString name=0, QObject *parent = 0);
MyInt(const int &value,const QString name=0, QObject *parent = 0);
MyInt(const MyInt &value,const QString name=0,QObject *parent = 0);
int getInt() const;
public slots:
void setInt(const int &value);
void setInt(const MyInt &value);
signals:
void valueChanged(const int newValue);
private:
int intStore;
};
#endif
清单附录中的错误一米
error: invalid conversion from const MyInt* to MyInt* error:
initializing argument 1 of void QList::append(const T&) [with T = MyInt*]
如果任何人能够指出什么是错的,那将是很麻烦的。