본문 바로가기
SWE/Qt

[Qt예제코드] qDebug currentTime 출력하기

by S나라라2 2019. 9. 18.
반응형

잘못된 방법

qDebug("call paintEvent %s", QTime::currentTime().toString("hh:mm:ss"));

이렇게 사용하면 특수기호 출력됨

잘못된 방법

 

 

옳은 방법

#define qPrintable(string) (string).toLocal8Bit().constData()

qDebug("call paintEvent %s", qPrintable(QTime::currentTime().toString("hh:mm:ss")));

옳은 방법

위의 방법 안됐던 이유 모르겠음. 

왜 toLocal8Bit 그리고 constData로 바꿔줘야하는거지?

일반 string은 8bit 이 아닌가..?

 

 

 

시도해봤던 다른 방법 (동작함)

qDebug()<<"call paintEvent "<< QTime::currentTime().toString();

동작함. 대신 <QtDebug>를 인클루드 해야 한다.

출력 예제

근데 왜 cout 방식으로하면 따옴표(")가 붙는지 모르겠음.

 

반응형