c – 如何将QString发送到调试输出?

c – 如何将QString发送到调试输出?,第1张

概述参见英文答案 > QT 5.0 QDebug compilation error                                    2个 我无法使用QDebug在Qt中打印出QString. 以下是一些尝试(无效): QDebug(letters.toStdString()); QDebug(letters.toLatin1()); QDebug() << le 参见英文答案 > QT 5.0 QDebug compilation error2个
我无法使用QDeBUG在Qt中打印出QString.

以下是一些尝试(无效):

QDeBUG(letters.toStdString());    QDeBUG(letters.tolatin1());    QDeBUG() << letters.toUtf8();    QDeBUG() << letters.toWChararray();    QDeBUG() << letters.toStdString();    QDeBUG() << letters;

我包括:

#include <QtDeBUG>#include <QDeBUG>

我使用的是Qt 5.2.我还在我的项目文件中添加了CONfig = console

我的错误是“没有用于调用QDeBUG :: QDeBUG()的匹配函数”

对于QDeBUG,我也得到了“QDeBUG(QByteArray)含糊不清”(letters.tolatin1());

解决方法 这样做的正确方法是:
#include <QDeBUG>// snip...QString letters;qDeBUG() << letters;

小心使用qDeBUG()以小写字母开头,因为它与QDeBUG类不同.

请参见http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#qDebug.它是一个便捷函数,它返回已配置的QDeBUG对象.

总结

以上是内存溢出为你收集整理的c – 如何将QString发送到调试输出?全部内容,希望文章能够帮你解决c – 如何将QString发送到调试输出?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1236622.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存