2013-04-07 12 views
5

So che possiamo usare #if DEBUG #endif #else in C#, quindi penso che Qt ha lo stesso modo di fare che, in questo modo:In QT, come distinguere il debug e rilasciare in qualche modo come preprocessore

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"; 
} 

ma non ha funzionato.

+1

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

risposta

4

Le macro Qt corrette sono QT_DEBUG. Così si codice sarà:

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

Grazie così tanto. – Aliceljm