简体   繁体   中英

Qt Call fails in Release Mode

I've developed an application using Qt, VS2013 and Boost. It runs fine in Debug mode. But fails to run in Release mode. Here's a piece of code that runs fine while debugging but throws an exception in release mode:

std::string str = ui.labels->toPlainText().toStdString();

This call on the other hand works fine:

QString str = ui.labels->toPlainText();

Is there anything wrong with those lines of code? Other boost calls work fine. Thanks.

You're probably trying to do too many things at once, and that makes it hard to pinpoint where it fails. Try it step-by-step:

QString const text = ui.labels->toPlainText();
QByteArray const utf8 = text.toUtf8();
auto const str = utf8.toStdString();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM