我需要创建一个QVectorIterator来迭代QVector of QStrings,如下所示:
#include <QString>
#include <QVectorIterator>
#include <QLabel>
#include <QTimer>
class Dice : public QLabel
{
Q_OBJECT
private:
QVector<QString> dice_faces;
QVectorIterator<QString> it( dice_faces );
QTimer *timer;
...但是我得到了这个错误,不知道是什么问题,或者QVectorIterator不能在QString向量上迭代吗?
Dice.h:16: error: 'dice_faces' is not a type
QVectorIterator<QString> i( dice_faces );
^发布于 2014-12-14 21:15:12
您需要在构造函数的初始化器列表中初始化迭代器。
#include <QString>
#include <QVectorIterator>
#include <QLabel>
#include <QTimer>
class Dice : public QLabel
{
Q_OBJECT
public:
Dice(QObject *parent);
private:
QVector<QString> dice_faces;
QVectorIterator<QString> it( dice_faces );
QTimer *timer;
// ...dice.cpp
// ...
Dice::Dice(QObject *parent)
: QLabel(parent),
it(dice_faces)
{
}https://stackoverflow.com/questions/27474088
复制相似问题