Hello there, I am legolizard, and I am very new to these forums, yet I would like the reader to note that I have in fact gone over other threads with a similar problem, and found them to be of no help. 
Furthermore, while I am relatively new to Qt, I am not new to C++, and have had a pretty easy time learning all the do-hickies of Qt. However, for some reason no matter what I do I always get "no appropriate default constructor."
My basic code is the following :
fileExplorer.hpp :
#ifndef FILEEXPLORER_H
#define FILEEXPLORER_H
#include <QDialog>
#include <QtCore>
#include <QtGui>
namespace Dialog{
class FileExplorer;
}
class FileExplorer
: public QDialog{ Q_OBJECT
private:
QFileSystemModel* dirmodel;
QFileSystemModel* filemodel;
Dialog::FileExplorer* dialogbox;
public:
explicit FileExplorer
(QWidget* parent
= 0 ,
QString path
= "C:\\");
//<--This is the !@#$ing default constructor, since I have defaults. ~FileExplorer();
};
#endif // FILEEXPLORER_H
#ifndef FILEEXPLORER_H
#define FILEEXPLORER_H
#include <QDialog>
#include <QtCore>
#include <QtGui>
namespace Dialog{
class FileExplorer;
}
class FileExplorer : public QDialog{
Q_OBJECT
private:
QFileSystemModel* dirmodel;
QFileSystemModel* filemodel;
Dialog::FileExplorer* dialogbox;
public:
explicit FileExplorer(QWidget* parent = 0 , QString path = "C:\\");//<--This is the !@#$ing default constructor, since I have defaults.
~FileExplorer();
};
#endif // FILEEXPLORER_H
To copy to clipboard, switch view to plain text mode
fileExplorer.cpp:
#include "fileExplorer.hpp"
#include "ui_fileExplorer.h"
FileExplorer
::FileExplorer(QWidget* parent ,
QString path
) : QDialog(parent
) , dirmodel
(new QFileSystemModel
(this)) ,
filemodel(new QFileSystemModel(this)) , dialogbox(new Dialog::FileExplorer){//<--Error here I guess?
dirmodel->setRootPath(path);
dirmodel
->setFilter
(QDir::NoDotAndDotDot |
QDir::AllDirs);
filemodel->setRootPath(path);
filemodel
->setFilter
(QDir::NoDotAndDotDot |
QDir::Files);
}
FileExplorer::~FileExplorer(){
delete dirmodel;
delete filemodel;
delete dialogbox;
}
#include "fileExplorer.hpp"
#include "ui_fileExplorer.h"
FileExplorer::FileExplorer(QWidget* parent , QString path) : QDialog(parent) , dirmodel(new QFileSystemModel(this)) ,
filemodel(new QFileSystemModel(this)) , dialogbox(new Dialog::FileExplorer){//<--Error here I guess?
dirmodel->setRootPath(path);
dirmodel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
filemodel->setRootPath(path);
filemodel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
}
FileExplorer::~FileExplorer(){
delete dirmodel;
delete filemodel;
delete dialogbox;
}
To copy to clipboard, switch view to plain text mode
I really like Qt and find it really easy and powerful, yet this one thing is really bothersome, and I feel stupid because it seems like such a simple thing to fix. x_x
Any help will be greatly appreciated, thank you. ^.^
Bookmarks