What changed with QString::toStdString() in QT6?
-
I had many problems with this myself when we started converting from wxWidgets to Qt. In that case it was some library mismatches. (In our case it was dynamic and static linking instead of release and debug.) Sometimes it has also to do with C++11 and C++98 being mixed.
However, our solution was to call
str.toUtf8().data()
. This has always worked. Also, it ensures that output, writing to text files, etc. is always UTF8 (which I believe it will not if usingstr.toStdString()
). In addition on Windows (and only Windows!!) we callsetlocale(LC_ALL, ".UTF8");
right at the beginning of main. This lets Windows know that all output onstd::cout
is actually UTF8. -
@JonB said in What changed with QString::toStdString() in QT6?:
I guess you are saying that sticking to release- or debug-only for everything has resolved your problem?
Yes, I built release and debug versions of QT6.2RC1. If I build debug app with debug QT and release app with release QT it does not crash.
-
@Xinlong Yes, you can not mix different msvc runtimes in one executable.