<?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[I cannot include &quot;QApplication&quot; into a QtQuick project. I&#x27;m using Visual Studio 2022.]]></title><description><![CDATA[<p dir="auto">So basically i tried using QtCharts, and i got an error, i found out i need to change my <code>QGuiApplication</code> into <code>QApplication</code>.<br />
As far as i read on the internet i just had to <code>#include &lt;QtWidgets/qapplication.h&gt;</code><br />
and i ended up with code like this:</p>
<pre><code>#include &lt;QGuiApplication&gt;
#include &lt;QQmlApplicationEngine&gt;
#include &lt;QtWidgets/qapplication.h&gt;`

int main(int argc, char* argv[]) {
#if defined(Q_OS_WIN)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

    QApplication app(argc, argv);

    QQmlApplicationEngine engine;

    engine.addImportPath("qrc:/");

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}

</code></pre>
<p dir="auto">and it should work. Unfortunately it don't.</p>
<p dir="auto">How can i fix this error.?</p>
<p dir="auto">My compiler can find this file but it can't find <code>qapplication.cpp</code> where all the definitions are.<br />
I also do not have any .pro file neither qmake or cmake.</p>
<p dir="auto">Do i need to install something in qt maintenance tool (i already installed Qt Charts)<br />
Do i need to create a new project? (i would preffer not to)</p>
<p dir="auto">My Qt version: 6.4.0<br />
My compiler version: <img src="https://ddgobkiprc33d.cloudfront.net/b11c1df7-4a40-4819-b1d8-27728b767f18.png" alt="35ea9c48-527e-40dd-9ebc-293d76d0630c-obraz.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/141982/i-cannot-include-qapplication-into-a-qtquick-project-i-m-using-visual-studio-2022</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 22:44:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141982.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Jan 2023 21:15:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I cannot include &quot;QApplication&quot; into a QtQuick project. I&#x27;m using Visual Studio 2022. on Fri, 06 Jan 2023 12:58:13 GMT]]></title><description><![CDATA[<p dir="auto">Okay i got it working.<br />
I'm using <code>Qt Vs Tools</code> extension.<br />
To make it work i had to open:<br />
<code>Extensions &gt; Qt VS Tools &gt; Qt Project Settings &gt; Qt Project Settings (on the left) &gt; Qt Modules</code><br />
and inside that check <code>QT Widgets</code>.<br />
I guess this is something like a pseudo <code>.pro</code> file or something.<br />
and after including <code>#include &lt;QtWidgets/qapplication.h&gt;</code> inside <code>main.cpp</code><br />
and changing from <code>QGuiApplication</code> to <code>QApplication</code> inside <code>main.cpp</code><br />
everything worked, i got no errors and a chart.</p>
<p dir="auto">Thank you for ur time @J-Hilk and <a class="plugin-mentions-user plugin-mentions-a" href="/user/tomz">@<bdi>TomZ</bdi></a></p>
]]></description><link>https://forum.qt.io/post/742793</link><guid isPermaLink="true">https://forum.qt.io/post/742793</guid><dc:creator><![CDATA[ZeeoTwo]]></dc:creator><pubDate>Fri, 06 Jan 2023 12:58:13 GMT</pubDate></item><item><title><![CDATA[Reply to I cannot include &quot;QApplication&quot; into a QtQuick project. I&#x27;m using Visual Studio 2022. on Fri, 06 Jan 2023 12:32:12 GMT]]></title><description><![CDATA[<p dir="auto">@J-Hilk</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zeeotwo">@<bdi>ZeeoTwo</bdi></a> there's a QML version of QCharts:</p>
</blockquote>
<p dir="auto">i know there is a qml version but i can't use it without changing from <code>QGuiApplication</code> to <code>QApplication</code></p>
<p dir="auto">this is my qml file that im loading using <code>loader</code> into my <code>main.qml</code>:</p>
<pre><code>import QtQuick
import QtCharts 2.4
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import Config 1.0
    Rectangle{
        id: home
    
            ChartView {
            id: chart
            title: "Top-5 car brand shares in Finland"
            anchors.fill: parent
            legend.alignment: Qt.AlignBottom
            antialiasing: true

                PieSeries {
                    id: pieSeries
                    PieSlice { label: "Volkswagen"; value: 13.5 }
                    PieSlice { label: "Toyota"; value: 10.9 }
                    PieSlice { label: "Ford"; value: 8.6 }
                    PieSlice { label: "Skoda"; value: 8.2 }
                    PieSlice { label: "Volvo"; value: 6.8 }
                }
            }
    }

</code></pre>
<p dir="auto">and after running it using QGuiApplication i get:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/9f2bfb8c-d59d-42f2-8aba-29ae1c50ca00.png" alt="8049efaf-64ec-4e61-b331-910f7f7e220c-image.png" class=" img-fluid img-markdown" /><br />
<img src="https://ddgobkiprc33d.cloudfront.net/d2e42c66-3ba9-42c9-8071-d6d3c1aedc8f.png" alt="1c1d324b-a89d-40c3-a850-24d48c234f08-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/742784</link><guid isPermaLink="true">https://forum.qt.io/post/742784</guid><dc:creator><![CDATA[ZeeoTwo]]></dc:creator><pubDate>Fri, 06 Jan 2023 12:32:12 GMT</pubDate></item><item><title><![CDATA[Reply to I cannot include &quot;QApplication&quot; into a QtQuick project. I&#x27;m using Visual Studio 2022. on Fri, 06 Jan 2023 07:01:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zeeotwo">@<bdi>ZeeoTwo</bdi></a> there's a QML version of QCharts:<br />
<a href="https://doc.qt.io/qt-6/qtcharts-qmlchart-example.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qtcharts-qmlchart-example.html</a></p>
<p dir="auto">use that one. Don't mix QML and QWidget if you don't have to &amp; also the qml variant is much more performant than the QWidget one</p>
]]></description><link>https://forum.qt.io/post/742731</link><guid isPermaLink="true">https://forum.qt.io/post/742731</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 06 Jan 2023 07:01:54 GMT</pubDate></item><item><title><![CDATA[Reply to I cannot include &quot;QApplication&quot; into a QtQuick project. I&#x27;m using Visual Studio 2022. on Thu, 05 Jan 2023 22:54:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomz">@<bdi>TomZ</bdi></a> said in <a href="/post/742706">I cannot include "QApplication" into a QtQuick project. I'm using Visual Studio 2022.</a>:</p>
<blockquote>
<p dir="auto">So, what buildsystem do you use?</p>
</blockquote>
<p dir="auto">i found this folder in my project:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/bac93912-deac-474f-9095-8b06f0975991.png" alt="db103f37-9ac0-46e0-b7a0-5be4341f238b-image.png" class=" img-fluid img-markdown" /><br />
so qmake i guess but i do not have any <code>qmake</code> file in acctual project folder</p>
<blockquote>
<p dir="auto">You likely are simply not using the QWidgets module in your project.</p>
</blockquote>
<p dir="auto">Soo how can i start using it?<br />
Can i do it simply and fast or do i need to just learn qmake and figure it out?</p>
]]></description><link>https://forum.qt.io/post/742714</link><guid isPermaLink="true">https://forum.qt.io/post/742714</guid><dc:creator><![CDATA[ZeeoTwo]]></dc:creator><pubDate>Thu, 05 Jan 2023 22:54:22 GMT</pubDate></item><item><title><![CDATA[Reply to I cannot include &quot;QApplication&quot; into a QtQuick project. I&#x27;m using Visual Studio 2022. on Thu, 05 Jan 2023 21:29:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zeeotwo">@<bdi>ZeeoTwo</bdi></a> said in <a href="/post/742704">I cannot include "QApplication" into a QtQuick project. I'm using Visual Studio 2022.</a>:</p>
<blockquote>
<p dir="auto">I also do not have any .pro file neither qmake or cmake.</p>
</blockquote>
<p dir="auto">So, what buildsystem do you use?</p>
<p dir="auto">You likely are simply not using the QWidgets module in your project.</p>
]]></description><link>https://forum.qt.io/post/742706</link><guid isPermaLink="true">https://forum.qt.io/post/742706</guid><dc:creator><![CDATA[TomZ]]></dc:creator><pubDate>Thu, 05 Jan 2023 21:29:33 GMT</pubDate></item></channel></rss>