Test for default-constructed QFileInfo

Viewed 258

I want to use an optional argument of type QFileInfo. What is the canonical way to test if the caller provided a value or if the default was used?

// declaration
void foo(QFileInfo fi = QFileInfo());

// definition
void foo(QFileInfo fi)
{
    if ( /* what to test for: "is default" */ ) {

    }
}

Usually default-constructed Qt objects have something like isValid() or isEmpty(). However, there seems no such thing in QFileInfo.

One option would be fi.filePath().isEmpty(). Is there something better / simpler?

2 Answers
Related