<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Is there a general Qt #define that can be checked for?]]></title><description><![CDATA[<p dir="auto">I have some code files that I would like to share between different platforms (some of which are not supported by Qt). I want to be able to check if it the file is being compiled in a Qt environment and then use some Qt features. Is there a #define that can be checked for presence of the Qt framework to achieve this?</p>
<p dir="auto">Hypothetical example:</p>
<p dir="auto">@<br />
#ifdef QT_FRAMEWORK_AVAILABLE</p>
<p dir="auto">#include &lt;QApplication&gt;</p>
<p dir="auto">double randomInRange(double min, double max)<br />
{<br />
return min + (max - min) * ((double)qrand() / (RAND_MAX + 1));<br />
}</p>
<p dir="auto">#elseif</p>
<p dir="auto">double randomInRange(double min, double max)<br />
{<br />
return min + (max - min) * ((double)rand() / (RAND_MAX + 1));<br />
}</p>
<p dir="auto">#endif<br />
@</p>
]]></description><link>https://forum.qt.io/topic/36381/is-there-a-general-qt-define-that-can-be-checked-for</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 07:03:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/36381.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 09 Jan 2014 09:03:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Is there a general Qt #define that can be checked for? on Thu, 09 Jan 2014 12:49:06 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for this.</p>
<p dir="auto">QT_CORE_LIB should probably be sufficient for all the cases I will ever encounter.</p>
]]></description><link>https://forum.qt.io/post/210075</link><guid isPermaLink="true">https://forum.qt.io/post/210075</guid><dc:creator><![CDATA[Eonz]]></dc:creator><pubDate>Thu, 09 Jan 2014 12:49:06 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a general Qt #define that can be checked for? on Thu, 09 Jan 2014 12:44:20 GMT]]></title><description><![CDATA[<p dir="auto">You can use QT_VERSION for example or in the case written above also QT_CORE_LIB might be possible.</p>
]]></description><link>https://forum.qt.io/post/210072</link><guid isPermaLink="true">https://forum.qt.io/post/210072</guid><dc:creator><![CDATA[butterface]]></dc:creator><pubDate>Thu, 09 Jan 2014 12:44:20 GMT</pubDate></item></channel></rss>