Results 1 to 2 of 2

Thread: qDebug() 's issue

  1. #1

    Default qDebug() 's issue

    im chinese,so where i use qDebug() found a issue.qDebug() can't not output a chinese character in Winxp.
    i follow this bug in qcoreapplication_win.cpp in corelib folder function qWinMsgHandler

    Qt Code:
    1. Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str)
    2. {
    3. Q_UNUSED(t);
    4. // OutputDebugString is not threadsafe.
    5.  
    6. // cannot use QMutex here, because qWarning()s in the QMutex
    7. // implementation may cause this function to recurse
    8. static QWinMsgHandlerCriticalSection staticCriticalSection;
    9.  
    10. if (!str)
    11. str = "(null)";
    12.  
    13. staticCriticalSection.lock();
    14. QT_WA({
    15. QString s(QString::fromLatin1(str));
    16. s += QLatin1String("\n");
    17. OutputDebugStringW((TCHAR*)s.utf16());
    18. }, {
    19. QByteArray s(str);
    20. s += "\n";
    21. OutputDebugStringA(s.data());
    22. })
    23. staticCriticalSection.unlock();
    24. }
    To copy to clipboard, switch view to plain text mode 


    bug in QString s(QString::fromLatin1(str)); if str is a gb18030 codec.then will get a error code
    Last edited by wysota; 1st September 2008 at 09:12. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qDebug() 's issue

    try to set needed codec for c-strings usgin this method:
    Qt Code:
    1. ...
    2. int main(int argc, char **argv)
    3. {
    4. ...
    5. QTextCodec::setCodecForCStrings(QTextCodec::codecForName(....));
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Crashing without qDebug() ?
    By xtreme in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2008, 17:01
  2. qDebug with/without MSVC
    By vonCZ in forum Newbie
    Replies: 2
    Last Post: 20th June 2007, 12:58
  3. Disable qDebug output
    By the_bis in forum Qt Programming
    Replies: 7
    Last Post: 30th November 2006, 20:14
  4. qDebug macro substitution
    By the_bis in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2006, 08:31
  5. qDebug() output
    By Doug Broadwell in forum Newbie
    Replies: 1
    Last Post: 1st November 2006, 21:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.