2013-04-07 11 views
5

Ich weiß, veröffentlichen wir #if DEBUG #else #endif in C# verwenden können, so dass ich denke, Qt die gleiche Art und Weise, wie dies zu tun hat:In QT, wie Debug zu unterscheiden und in someway wie Präprozessor

QString Paths::sqlScriptPath() 
{ 
#if DEBUG 
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Debug\sql"; 
#else 
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Release\sql"; 
} 

aber es hat nicht funktioniert.

+1

ähnliche Frage: http://stackoverflow.com/questions/11714118/detect-if-qt-is-running-a-debug-build-at-runtime – warunanc

Antwort

4

Die richtigen Qt-Makros dafür sind QT_DEBUG. So werden Sie Code sein:

QString Paths::sqlScriptPath() 
{ 
#ifdef QT_DEBUG 
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Debug\sql"; 
#else 
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Release\sql"; 
#endif 
} 
+0

Danke so sehr. – Aliceljm