You can use:
QString qs;
// do things
std::cout << qs.toStdString() << std::endl;
It internally uses QString::toUtf8() function to create std::string, so it’s Unicode safe as well. Here’s reference documentation for QString
.
More Related Contents:
- QString to char* conversion
- How to change string into QString?
- cannot convert ‘const char*’ to ‘LPCWSTR {aka const wchar_t*}’
- Convert std::string to QString
- Problems converting float to int in C++
- Why QFile(“./test”) work though [Class QFile] has no QFile(char* s) constructor
- Connecting overloaded signals and slots in Qt 5
- How to use the Qt’s PIMPL idiom?
- the procedure entry point __gxx_personality_v0 could not be located
- Qt5 Static Build yields Failed to load platform plugin “windows”
- QtCore.QObject.connect in a loop only affects the last instance
- Qt signals (QueuedConnection and DirectConnection)
- How to leverage Qt to make a QObject method thread-safe?
- How to deploy a Qt application on Windows?
- How to emit cross-thread signal in Qt?
- C++ Qt signal and slot not firing
- Make QWidget transparent
- How do I create a Window in different QT threads?
- Qt Creator – Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild
- GIF animation in Qt
- How to append text to QPlainTextEdit without adding newline, and keep scroll at the bottom?
- Slot is being called multiple times every time a signal is emitted
- QPSQL driver not loaded Qt
- Changing locale in Qt
- QScrollArea with dynamically changing contents
- Using emit vs calling a signal as if it’s a regular function in Qt
- How to create/read/write JSON files in Qt5
- Error: C2228: left of ” must have class/struct/union
- Convert std::variant to another std::variant with super-set of types
- How to convert int to string in C++