Qt Call fails in Release Mode

2019-09-02 15:48发布

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.

1条回答
放荡不羁爱自由
2楼-- · 2019-09-02 16:30

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();
查看更多
登录 后发表回答