I need the instance of p to by of type QObject it seems, I have extended QObject and defined the keyword Q_OBJECT in fileprocessor.h, I am not sure what else I can do.
-Fileprocessor.h
#ifndef FILEPROCESSOR_H
#define FILEPROCESSOR_H
#include <QMainWindow>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QStandardItemModel>
#include <QObject>
class fileProcessor: public QObject
{
Q_OBJECT
public:
fileProcessor();
public slots:
void on_action_Open_triggered();
void checkString(QString &temp, QChar ch = 0);
public:
QList<QStringList> csv;
QStandardItemModel *model;
QList<QStandardItem*> standardItemList;
};
#endif // FILEPROCESSOR_H
-Mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "fileProcessor.h"
MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{
fileProcessor p;
ui->setupUi(this);
QObject::connect(ui->Open, SIGNAL(clicked()),
p,SLOT(on_action_Open_triggered()));
}
MainWindow::~MainWindow()
{
delete ui;
}
-Mainwindow.cpp
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QStandardItemModel>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
Error:
C:\Qt\Qt5.3.2\Tools\QtCreator\bin\Assignment3\mainwindow.cpp:10: error: C2664: 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const' : cannot convert argument 3 from 'fileProcessor' to 'const QObject *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called