<?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[Problem with passing object of my class as parameter to other object.]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm working on text editor in Qt and I have a small problem. There are 2 classes MainWindow and Editor and what I'm trying to do is to pass one of the as a parameter to the other.</p>
<p dir="auto">Here is the <a href="https://gist.github.com/cmoud94/3521b5dc6b742ad74929cae37d5eaddc" target="_blank" rel="noopener noreferrer nofollow ugc">LINK</a> to gist containing header files of that 2 classes.</p>
<p dir="auto">If I compile this code it gives me two errors:</p>
<ul>
<li>editor.h:13: error: expected ')' before '*' token</li>
</ul>
<pre><code>Editor(MainWindow *parent, QString path, QString name, QString content);
</code></pre>
<ul>
<li>editor.h:23: error: 'MainWindow' does not name a type</li>
</ul>
<pre><code>MainWindow *parent;
</code></pre>
<p dir="auto">Thanks for help.</p>
]]></description><link>https://forum.qt.io/topic/65786/problem-with-passing-object-of-my-class-as-parameter-to-other-object</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 23:28:11 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/65786.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Apr 2016 14:24:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 20:04:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">That circular dependency triggers another question: why do you need it ? Sounds like you are preparing a tight coupling between these two classes and it's something you should avoid.</p>
]]></description><link>https://forum.qt.io/post/321015</link><guid isPermaLink="true">https://forum.qt.io/post/321015</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 05 Apr 2016 20:04:01 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 18:36:26 GMT]]></title><description><![CDATA[<p dir="auto">Thanks a lot guys, forward declaration solved it.</p>
]]></description><link>https://forum.qt.io/post/321007</link><guid isPermaLink="true">https://forum.qt.io/post/321007</guid><dc:creator><![CDATA[cmoud94]]></dc:creator><pubDate>Tue, 05 Apr 2016 18:36:26 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 17:25:39 GMT]]></title><description><![CDATA[<p dir="auto">I was going to suggest the same as @jsulm.  Use forward declaration of MainWindow in your header and include the header in your CPP.</p>
]]></description><link>https://forum.qt.io/post/320995</link><guid isPermaLink="true">https://forum.qt.io/post/320995</guid><dc:creator><![CDATA[DRoscoe]]></dc:creator><pubDate>Tue, 05 Apr 2016 17:25:39 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 15:44:27 GMT]]></title><description><![CDATA[<p dir="auto">Don't forget to include MainWindow in Editor.cpp</p>
]]></description><link>https://forum.qt.io/post/320985</link><guid isPermaLink="true">https://forum.qt.io/post/320985</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 05 Apr 2016 15:44:27 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 15:43:40 GMT]]></title><description><![CDATA[<p dir="auto">You have circular includes: MainWindow includes Editor and Editor includes MainWindows. This is not going to work.<br />
If you only use pointer to MainWindow in Editor you can remove the include and add forward declaration:</p>
<pre><code>class MainWindow;
</code></pre>
]]></description><link>https://forum.qt.io/post/320984</link><guid isPermaLink="true">https://forum.qt.io/post/320984</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 05 Apr 2016 15:43:40 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 14:47:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> Hi, thanks for fast reply. Include is not the issue here, if you look at the gist I've posted link to, you'll see that I have "mainwindow.h" included in "editor.h".</p>
]]></description><link>https://forum.qt.io/post/320978</link><guid isPermaLink="true">https://forum.qt.io/post/320978</guid><dc:creator><![CDATA[cmoud94]]></dc:creator><pubDate>Tue, 05 Apr 2016 14:47:16 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with passing object of my class as parameter to other object. on Tue, 05 Apr 2016 14:32:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cmoud94">@<bdi>cmoud94</bdi></a> said:</p>
<blockquote>
<p dir="auto">MainWindow' does not name a type</p>
</blockquote>
<p dir="auto">hi, this sounds like you did not include "mainwindow.h"<br />
so it knows that type?</p>
]]></description><link>https://forum.qt.io/post/320975</link><guid isPermaLink="true">https://forum.qt.io/post/320975</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 05 Apr 2016 14:32:15 GMT</pubDate></item></channel></rss>