I was playing with QT and I found a small issue. (I am really new in Qt). After search about that, I did not find anything. The problem is: In header file:
#include <QMainWindow>
namespace Ui {
class jAudio;
}
class jAudio : public QMainWindow
{
Q_OBJECT
public:
explicit jAudio(QWidget *parent = 0);
~jAudio();
private:
Ui::jAudio *ui;
private slots:
void jSetup (void);
void jInfo (QString);
void jFillComboBox(QComboBox, QStringList);
void on_bRecord_clicked();
};
And I declare the method in .cpp file like:
#include "jaudio.h"
#include "ui_jaudio.h"
void jAudio::jFillComboBox(QComboBox comboBox, QStringList data){
for (int i = 0; i< options.count(); i++){
comboBox->addItem(data[i],i);
}
}
When I try to run the code then the error appear:
..../jAudio/jaudio.h:25: error:
‘QComboBox’ has not been declared
void jFillComboBox(QComboBox, QStringList);
Do you know what am I doing wrong?
Thnak you very much!!
In jAudio.h: add #include <QComboBox>
and #include <QStringList>
. And change jFillComboBox
to jFillComboBox(QComboBox*, QStringList)
, as previously mentioned in comments. The reasoning for the second part is that QComboBox
is derived from QWidget
, and QWidget
objects cannot be copied. If you've come from other, higher-level languages, the concept of non-copyable objects and passing-by-pointer (or reference) may be foreign to you. If that's the case, consider looking through this question and the links there.