cannot convert ‘const QString’ to ‘const QLocale&’
-
@xavierbaez said in cannot convert ‘const QString’ to ‘const QLocale&’:
here’s the code
No, this is not the code causing that error...
-
@xavierbaez
Nobody can answer from this without knowing what classBasicLogger
is, since it's not a supplied Qt class, and hence the definition ofmatch()
if you are overriding it (or perhaps some other context)? You are amazingly "economical" with what you show in order to answer your question, I cannot understand why. In itself there is nothing you show which would error requiringQLocale
instead of theQString
you specify. -
@xavierbaez said in cannot convert ‘const QString’ to ‘const QLocale&’:
QRegExp
This was deprecated in Qt5 and removed in Qt6 so I would be surprised if this compiles at all.
-
@Christian-Ehrlicher said in cannot convert ‘const QString’ to ‘const QLocale&’:
@xavierbaez said in cannot convert ‘const QString’ to ‘const QLocale&’:
QRegExp
This was deprecated in Qt5 and removed in Qt6 so I would be surprised if this compiles at all.
Would you be so kind to let me know how would you write this?
-
@xavierbaez said in cannot convert ‘const QString’ to ‘const QLocale&’:
QRegExp re(QString(matchPattern).arg(_params.fileName)); return re.exactMatch(logFileName);
Try (untested)
QRegularExpression re(QRegularExpression::anchoredPattern(QString(matchPattern).arg(_params.fileName))); return re.match(logFileName).hasMatch();
You will need to change
#include <QRegExp>
to#include <QRegularExpression>
. -
Hallo,
i got the same problem converting from Qt 5 to Qt 6. I understand the problem, but i don't know how to fix it.
In my source it is this:app.installTranslator(&TTranslator); //this is fine QLocale::setDefault(TSettings->language); //this is wrong
While TSettings->language is a QString reading from QSettings.
-
@Volker75
QLocale(const QString&)
constructor was markedexplicit
in Qt6, so you have to, well, be explicit when you use that constructor :)QLocale::setDefault(QLocale(TSettings->language));
-
@Chris-Kawa said in cannot convert ‘const QString’ to ‘const QLocale&’:
QLocale(
ah... so easy.. Thank you very much! I just tried and it can compile now that file. (Not the whole project yet, there are more errors, but i hope i can fix them myself)
-
@JonB said in cannot convert ‘const QString’ to ‘const QLocale&’:
@xavierbaez said in cannot convert ‘const QString’ to ‘const QLocale&’:
QRegExp re(QString(matchPattern).arg(_params.fileName)); return re.exactMatch(logFileName);
Try (untested)
QRegularExpression re(QRegularExpression::anchoredPattern(QString(matchPattern).arg(_params.fileName))); return re.match(logFileName).hasMatch();
You will need to change
#include <QRegExp>
to#include <QRegularExpression>
.Yeah that worked thank you so much.
-