Windows 10 QDir::separator
-
I am building a path, I start off by using QFileDialog::getExistingDirectory to get a chosen path from the operator. On Windows 10 the path returned by this function contains / delimiting the folders.
I then check if the returned path needs a delimiter appending with:
QString strPath(QFileDialog::getExistingDirectory(this, "Choose location")); QChar chSeparator(QDir::separator()); if ( strPath.endsWith(chSeparator) != true ) { strPath += chSeparator; }
I can see in the debugger that chSeprator contains \ not the same delimiter as returned by getExistingDirectory, why is this and am I checking this correctly?
-
@SPlatten Qt uses / even on Windows. QDir::separator() returns native separator as explained in documentation (means: on Windows \). You can simply check for both / and \. Keep in mind that you have to escape \ if you want to use it in your paths.
-
People should really learn to sue the Search function... this same question was asked exactly three days ago: https://forum.qt.io/topic/128692/