Path/Directory separator inconsistent.
-
@J-Hilk , this was the code:
QChar separator = QDir::separator(); QString newPath(path); if (!newPath.endsWith(separator)) { newPath += separator; }
@JonB, you can't pass QDir::separator() to QDir::toNativeSeparators as there is only one version of this function and it expects a QString not a QChar.
It's all just messy and requires thought and effort when it should be handled internally.
@SPlatten said in Path/Directory separator inconsistent.:
@JonB, you can't pass QDir::separator() to QDir::toNativeSeparators as there is only one version of this function and it expects a QString not a QChar.
Why do you make this kind of statement without checking?
QString sep = QDir::toNativeSeparators(QDir::separator());
-
@SPlatten
No, you did not try the code! There is just the one function in my version of Qt too! And it accepts the same parameter type as yours....static QString toNativeSeparators(const QString &pathName);
, https://doc.qt.io/qt-5/qdir.html#toNativeSeparators. -
@SPlatten
No, you did not try the code! There is just the one function in my version of Qt too! And it accepts the same parameter type as yours....static QString toNativeSeparators(const QString &pathName);
, https://doc.qt.io/qt-5/qdir.html#toNativeSeparators. -
@JonB , Qt Creator 4.2.1, Based on Qt 5.8.0 (MSCV 2015, 32 bit), thats the version on the laptop I'm using for this project and I can sure you that the version only excepts a const QString&, there is no alternative in this IDE.
@SPlatten
It has nothing to do with the IDE, at all.I can sure you
It does have to do with the behaviour of C++, and
QString
....Would you be kind enough to copy & paste my line into your version, and tell me the outcome, please? Show me the error message you get at compile-time, thank you.
-
@JonB How can I try it when it won't compile without errors? Stop shouting and calm down!
-
@JonB How can I try it when it won't compile without errors? Stop shouting and calm down!
@SPlatten Sorry, but I have to support @JonB here: that line of code compiles just fine.
"it returns a QChar" - which converts just fine to a QString (https://doc.qt.io/qt-5/qstring.html#QString-2). -
@SPlatten
Could you please put it into your code, and show me the compile-time error message you get, as requested? I should be most obliged....