[Qt-interest] QFile private member

Pete Christensen qt at graffiti.graceland.ca
Tue Feb 10 21:03:26 CET 2009


OK, I give up, I can not do this. How do I declare a private member 
variable of type QFile and initialize it in the constructor? I can find 
nothing in the documentation nor in this newsgroup that tells me how. Am 
I the only one who has wanted to do this? Qt 4.4.3.

privatefile.h

#ifndef PRIVATEFILE_H_
#define PRIVATEFILE_H_

#include <QString>
#include <QFile>

class PrivateFile {
public:
	PrivateFile(const QString &fileName);
private:
	QFile file;
};

#endif

privatefile.cpp

#include "privatefile.h"

PrivateFile::PrivateFile(const QString &fileName) {
	file.setFileName(fileName);
	//??
}

Compiler complains:
/usr/include/qt4/QtCore/qfile.h:191: error: ‘QFile::QFile(const QFile&)’ 
is private

!!!!!!!!!!!!

How can this be done? There is something wrong with the way I'm 
declaring file member in privatefile.h, but I do not understand what.



More information about the Qt-interest-old mailing list