Reputation: 955
I have a QMutableStringListIterator
that I want to use to iterate through a QStringList
, but I keep getting an error in the .h
file that says my QStringList
is not a type. Why?
myClass.h
#ifndef MYCLASS_H
#define MYCLASS_H
#include <QDockWidget>
#include <QList>
#include <QStringList>
#include <QMutableStringListIterator>
namespace Ui {
class MyClass;
}
class MyClass: public QDockWidget
{
Q_OBJECT
public:
explicit MyClass(QWidget* parent = 0);
void someFunc(QString message);
~MyClass();
private:
Ui::Messages* ui;
QStringList myList;
QMutableStringListIterator iterator(myList); // it errors here. "myList is not a type"
};
#endif // MYCLASS_H
MyClass.cpp
#include "myclass.h"
#include <QString>
#include <QDebug>
#include <QCoreApplication>
MyClass::MyClass(QWidget* parent) :
QDockWidget(parent),
ui(new Ui::MyClass),
iterator(myList)
{
ui->setupUi(this);
}
MyClass::~MyClass()
{
delete ui;
}
void MyClass::someFunc(QString message) {
myList.append(message);
qDebug() << myList.length();
}
Upvotes: 0
Views: 271
Reputation: 955
I fixed it. Here's what the .h
file should look like:
private:
Ui::Messages* ui;
QStringList myList;
QMutableStringListIterator iterator; // do not give it the myList here
};
Upvotes: 1