Check whether a string is a valid filename with Qt

Posted by ereOn on Stack Overflow See other posts from Stack Overflow or by ereOn
Published on 2010-06-14T15:11:34Z Indexed on 2010/06/14 15:32 UTC
Read the original article Hit count: 292

Filed under:
|
|
|

Hi,

Is there a way with Qt 4.6 to check if a given QString is a valid filename (or directory name) on the current operating system ? I want to check for the name to be valid, not for the file to exist.

Examples:

// Some valid names
test
under_score
.dotted-name

// Some specific names
colon:name // valid under UNIX OSes, but not on Windows
what? // valid under UNIX OSes, but still not on Windows

How would I achieve this ? Is there some Qt built-in function ?

I'd like to avoid creating an empty file, but if there is no other reliable way, I would still like to see how to do it in a "clean" way.

Many thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about validation