<?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[Can&#x27;t create macro for QTextStream manipulator functions]]></title><description><![CDATA[<p dir="auto">I'm creating some macros to ease transition from Qt5 to Qt6 for some of my shared code.  For some reason, the QTextStream manipulator functions just don't want to be used in a macro!</p>
<p dir="auto">Here's example 1, and under Qt6 the Qt::endl line causes compiler error: "<em><strong>MyLib::Qt has not been declared</strong></em>".  This code is in my compat.h file which does not set a namespace.  Why is it even referencing MyLib:: ??  Notice the SkipEmbyParts macro works fine.</p>
<pre><code>// Example 1
#if QT_VERSION &lt; QT_VERSION_CHECK(5, 14, 0)
#define QT_COMPAT_SKIPEMPTYPARTS                   QString::SkipEmptyParts
#define QT_COMPAT_ENDL                             "\n"
#else
#define QT_COMPAT_SKIPEMPTYPARTS                   Qt::SkipEmptyParts
#define QT_COMPAT_ENDL                             Qt::endl
#endif
</code></pre>
<p dir="auto">And here's example number 2, in this case the ::Qt::flush causes compiler error: "<em><strong>Unexpected qualified id before '::' token</strong></em>".  I tried to prefix my manipulator with :: so that no higher level namespace would be assumed...but that chokes too.</p>
<pre><code>// Example 2
#if QT_VERSION &lt; QT_VERSION_CHECK(6, 0, 0)
#define QT_COMPAT_FLUSH                            flush
#else
#define QT_COMPAT_FLUSH                            ::Qt::flush
#endif
</code></pre>
<p dir="auto">Can someone help me fix my macros?</p>
]]></description><link>https://forum.qt.io/topic/157181/can-t-create-macro-for-qtextstream-manipulator-functions</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 10:30:44 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/157181.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Jun 2024 18:58:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can&#x27;t create macro for QTextStream manipulator functions on Wed, 12 Jun 2024 13:43:00 GMT]]></title><description><![CDATA[<p dir="auto">Ok, my error.  I was USING the macro incorrectly in one spot, writing MyLib::QT_COMPAT_FLUSH.  Once I just used the macro name all worked as expected.</p>
]]></description><link>https://forum.qt.io/post/802481</link><guid isPermaLink="true">https://forum.qt.io/post/802481</guid><dc:creator><![CDATA[ocgltd]]></dc:creator><pubDate>Wed, 12 Jun 2024 13:43:00 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t create macro for QTextStream manipulator functions on Mon, 10 Jun 2024 19:03:39 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Can you provide a minimal buildable example showing this ?</p>
]]></description><link>https://forum.qt.io/post/802280</link><guid isPermaLink="true">https://forum.qt.io/post/802280</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 10 Jun 2024 19:03:39 GMT</pubDate></item></channel></rss>