PDA

View Full Version : how to include QThread for main form



narlapavan
7th February 2012, 14:36
#ifndef FRMFIND_H
#define FRMFIND_H

#include <QMainWindow>
#include<QThread>

namespace Ui {
class frmFind;
}

class frmFind : public QMainWindow, QThread
{
Q_OBJECT

public:
explicit frmFind(QWidget *parent = 0);
// void run();
void QThread::run();
~frmFind();
public slots:
void getDirNames();
private slots:
void on_btnSearch_clicked();

private:
Ui::frmFind *ui;
};

#endif // FRMFIND_H

when i am including QThread in above way for main Form , it giving this error
ERROR:
/PATHNAME/moc_frmfind.cpp:55: error: ‘QObject’ is an ambiguous base of ‘frmFind’

wysota
7th February 2012, 14:50
You can't inherit from two classes that are derived from QObject. Use composition instead. Also note that you can't access GUI objects from within a worker thread.