Soyal7
Soyal7

Reputation: 451

Initialize QFile with auto

I'm adopting the modern style of using auto type deduction and I can't figure out why this:

auto file = QFile{filepath};

gives the following error:

error C2280: 'QFile::QFile(const QFile &)': attempting to reference a deleted function

Upvotes: 0

Views: 232

Answers (2)

epsilon
epsilon

Reputation: 2969

The way you wrote your code, you call the QFile constructor, then its copy constructor. This last one is not defined in the QFile class, hence the compiler error message which told that this function has been deleted.

Therefore, you cannot really use auto here. But you can still initialize your QFile instance like:

QFile file{filepath};
// or
QFile file = {filepath};

Upvotes: 1

Zalberth
Zalberth

Reputation: 308

This function is already removed from your version of SDK or not marked as a public one anymore.

Upvotes: 0

Related Questions