<?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[error building a window application]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm stuck at debugging an issue.</p>
<p dir="auto">I have two windows <code>StageOneMain</code> and <code>ClinicalProtocolWindow</code></p>
<p dir="auto">I want to open <code>ClinicalProtocolWindow</code> from   <code>StageOneMain</code>  and go back.</p>
<p dir="auto">On  <code>StageOneMain</code>  I did the following:</p>
<pre><code>#ifndef STAGEONEMAIN_H
#define STAGEONEMAIN_H

#include &lt;QMainWindow&gt;
#include "clinicalprotocolwindow.h"


QT_BEGIN_NAMESPACE
namespace Ui { class StageOneMain; }
QT_END_NAMESPACE

class StageOneMain : public QMainWindow
{
    Q_OBJECT

public:
     StageOneMain(QString, QWidget *parent = nullptr);
    ~StageOneMain();
     ClinicalProtocolWindow *clinwindow;
     QString pLabel;
private:
    Ui::StageOneMain *ui;
};
#endif // STAGEONEMAIN_H
</code></pre>
<p dir="auto">.cpp</p>
<pre><code>void StageOneMain::on_pushButton_programs_clicked()
{

    this-&gt;close();
    clinwindow = new  ClinicalProtocolWindow(pLabel, nullptr);
    clinwindow -&gt; setAttribute(Qt::WA_DeleteOnClose);
    clinwindow -&gt; show();

}
</code></pre>
<p dir="auto">and  <code>ClinicalProtocolWindow</code> as follows:</p>
<pre><code>#ifndef CLINICALPROTOCOLWINDOW_H
#define CLINICALPROTOCOLWINDOW_H

#include &lt;QMainWindow&gt;
#include "stageonemain.h"

namespace Ui {
class ClinicalProtocolWindow;
}

class ClinicalProtocolWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit ClinicalProtocolWindow(QString, QWidget *parent = nullptr);
    ~ClinicalProtocolWindow();
    QString pLabel;

private slots:
    void on_pushButton_clicked();

private:
    Ui::ClinicalProtocolWindow *ui;
};

#endif // CLINICALPROTOCOLWINDOW_H
</code></pre>
<p dir="auto">and .cpp</p>
<pre><code>#include "clinicalprotocolwindow.h"
#include "ui_clinicalprotocolwindow.h"

ClinicalProtocolWindow::ClinicalProtocolWindow(QString patientLabel, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ClinicalProtocolWindow)
{
    ui-&gt;setupUi(this);
    pLabel = patientLabel;
}

ClinicalProtocolWindow::~ClinicalProtocolWindow()
{
    delete ui;
}

void ClinicalProtocolWindow::on_pushButton_clicked()
{

}

</code></pre>
<p dir="auto">I get the errors pointing below</p>
<pre><code>     ClinicalProtocolWindow *clinwindow;
</code></pre>
<p dir="auto">and the errors are:</p>
<pre><code>stageonemain.h:33: error: C2143: syntax error: missing ';' before '*'
stageonemain.h:33: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
stageonemain.h:33: error: C2238: unexpected token(s) preceding ';'

</code></pre>
<p dir="auto">It seems that I have overlooked something. I'm feeling frustrated and stuck on this problem.</p>
<p dir="auto">Can you spot any issues here?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/topic/144641/error-building-a-window-application</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 11:12:43 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/144641.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Apr 2023 14:37:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 15:47:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a> , <a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a>  , <a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a>  Many thanks for your feedback :)</p>
]]></description><link>https://forum.qt.io/post/756090</link><guid isPermaLink="true">https://forum.qt.io/post/756090</guid><dc:creator><![CDATA[russjohn834]]></dc:creator><pubDate>Tue, 25 Apr 2023 15:47:11 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 15:32:02 GMT]]></title><description><![CDATA[<p dir="auto">Few things in addition to the circular inclusion/dependency you did with your two classes :</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a> said in <a href="/post/756074">error building a window application</a>:</p>
<blockquote>
<p dir="auto">class ClinicalProtocolWindow : public QMainWindow</p>
</blockquote>
<p dir="auto">I wouldn't make <code> ClinicalProtocolWindow</code> a <code>QMainWindow</code>-based class unless you really need the toolbars and menus, which come with it.<br />
<code>QWidget</code> or even <code>QDialog</code> is better, esp. since you have <code>Qt::WA_DeleteOnClose</code> set.<br />
For example, create your dialog, fill in/change whatever you want to edit and return to your <code>mainWindow</code> again.<br />
(I assume it's gonna be some patient form)</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a> said in <a href="/post/756074">error building a window application</a>:</p>
<blockquote>
<p dir="auto">this-&gt;close();<br />
clinwindow = new  ClinicalProtocolWindow(pLabel, nullptr);<br />
clinwindow -&gt; setAttribute(Qt::WA_DeleteOnClose);<br />
clinwindow -&gt; show();</p>
</blockquote>
<p dir="auto">This could easily run into <code>QApplication:quitOnLastWindowClosed</code> when there are no other windows or parent widgets involved and then your app just exits without showing anything.</p>
<ul>
<li><a href="https://doc.qt.io/qt-6/qguiapplication.html#quitOnLastWindowClosed-prop" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qguiapplication.html#quitOnLastWindowClosed-prop</a></li>
</ul>
<p dir="auto">Make sure you have a parent window or change the order of <code>close()</code> / <code>hide()</code> and <code>show()</code></p>
]]></description><link>https://forum.qt.io/post/756085</link><guid isPermaLink="true">https://forum.qt.io/post/756085</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Tue, 25 Apr 2023 15:32:02 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 15:15:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a> as JonB pointed out, you have mutual include in these two header files. Use changes I made in your header and you will be good. Add include header in .cpp files.</p>
]]></description><link>https://forum.qt.io/post/756082</link><guid isPermaLink="true">https://forum.qt.io/post/756082</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Tue, 25 Apr 2023 15:15:41 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 15:15:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a><br />
If you read my answer it will tell you why.<br />
And if you look at <a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a>'s code you will see he has inserted</p>
<pre><code>class ClinicalProtocolWindow;
</code></pre>
<p dir="auto">and removed <code>#include "clinicalprotocolwindow.h"</code>.  Which will make it compilable.</p>
]]></description><link>https://forum.qt.io/post/756081</link><guid isPermaLink="true">https://forum.qt.io/post/756081</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 25 Apr 2023 15:15:07 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 15:12:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> said in <a href="/post/756077">error building a window application</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a> no line 33.</p>
</blockquote>
<p dir="auto">I modified the original .h file to show only what I thought would be relevant.<br />
It looks like something silly I'm doing!<br />
What is strange is , I have other windows works fine. The error is only when I added the new <code>ClinicalProtocolWindow</code></p>
]]></description><link>https://forum.qt.io/post/756079</link><guid isPermaLink="true">https://forum.qt.io/post/756079</guid><dc:creator><![CDATA[russjohn834]]></dc:creator><pubDate>Tue, 25 Apr 2023 15:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 15:12:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a><br />
You have two <code>.h</code> files, each trying to include the other.  Each has a "guard".</p>
<pre><code>#ifndef STAGEONEMAIN_H
#define STAGEONEMAIN_H

#include &lt;QMainWindow&gt;
#include "clinicalprotocolwindow.h"
</code></pre>
<p dir="auto">and</p>
<pre><code>#ifndef CLINICALPROTOCOLWINDOW_H
#define CLINICALPROTOCOLWINDOW_H

#include &lt;QMainWindow&gt;
#include "stageonemain.h"
</code></pre>
<p dir="auto">Follow through in your head/on a piece of paper what happens.  You will find that when</p>
<pre><code> ClinicalProtocolWindow *clinwindow;
</code></pre>
<p dir="auto">in <code>StageOneMain.h</code> is reached <code>ClinicalProtocolWindow</code> class is not defined. Hence the error messages.</p>
<p dir="auto">Mutual inclusion like this is <em>often</em> a sign a bad design.  I suspect it is here.  <em>Why</em> should both of these classes need to know al about each other just because you have two windows opening?</p>
<p dir="auto">Find a way to get round this.  Just having <code>StageOneMain.h</code> go <code>class ClinicalProtocolWindow;</code> like that may be enough to break to the dependency/error.  Or as it currently stands <code>ClinicalProtocolWindow</code> has no need to include <code>StageOneMain.h</code>.</p>
]]></description><link>https://forum.qt.io/post/756078</link><guid isPermaLink="true">https://forum.qt.io/post/756078</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 25 Apr 2023 15:12:39 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 14:56:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a> no line 33. Better to make variables private.</p>
<pre><code>#ifndef STAGEONEMAIN_H
#define STAGEONEMAIN_H

#include &lt;QMainWindow&gt;

QT_BEGIN_NAMESPACE
namespace Ui { class StageOneMain; }
QT_END_NAMESPACE

class ClinicalProtocolWindow;

class StageOneMain : public QMainWindow
{
    Q_OBJECT

public:
     StageOneMain(QString, QWidget *parent = nullptr);
    ~StageOneMain();

private:
    Ui::StageOneMain *ui{};     

    ClinicalProtocolWindow *clinwindow{};
    QString pLabel;
};
#endif // STAGEONEMAIN_H
</code></pre>
]]></description><link>https://forum.qt.io/post/756077</link><guid isPermaLink="true">https://forum.qt.io/post/756077</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Tue, 25 Apr 2023 14:56:14 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 14:50:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> Hi, thanks. I just modified it</p>
]]></description><link>https://forum.qt.io/post/756076</link><guid isPermaLink="true">https://forum.qt.io/post/756076</guid><dc:creator><![CDATA[russjohn834]]></dc:creator><pubDate>Tue, 25 Apr 2023 14:50:50 GMT</pubDate></item><item><title><![CDATA[Reply to error building a window application on Tue, 25 Apr 2023 14:45:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/russjohn834">@<bdi>russjohn834</bdi></a> your posted  header file is not complete.</p>
]]></description><link>https://forum.qt.io/post/756075</link><guid isPermaLink="true">https://forum.qt.io/post/756075</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Tue, 25 Apr 2023 14:45:40 GMT</pubDate></item></channel></rss>