<?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[Am I calling this method wrong?]]></title><description><![CDATA[<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/c8ced52c-a54e-47cb-b77a-81ded5eb5ec8.PNG" alt="header for class.PNG" class=" img-fluid img-markdown" /> <img src="https://ddgobkiprc33d.cloudfront.net/5a24c490-6365-4b03-bcdb-83dd285bcab9.PNG" alt="method.PNG" class=" img-fluid img-markdown" /> <img src="https://ddgobkiprc33d.cloudfront.net/ca478f27-457c-4cc3-aef1-56e89cfc1aa2.PNG" alt="object decl.PNG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/159382/am-i-calling-this-method-wrong</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 19:31:48 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/159382.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Oct 2024 01:56:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Am I calling this method wrong? on Fri, 25 Oct 2024 06:20:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/comedian">@<bdi>Comedian</bdi></a> One more observation: in on_portQuery_clicked() you create a local variable and then call openPort() on it. This local variable only lives inside on_portQuery_clicked() and will be deleted as soon as on_portQuery_clicked() finishes.</p>
]]></description><link>https://forum.qt.io/post/812931</link><guid isPermaLink="true">https://forum.qt.io/post/812931</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 25 Oct 2024 06:20:07 GMT</pubDate></item><item><title><![CDATA[Reply to Am I calling this method wrong? on Fri, 25 Oct 2024 02:33:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/comedian">@<bdi>Comedian</bdi></a></p>
<p dir="auto">Hi and welcome to the forum,</p>
<p dir="auto">it's always better to post code as text using the code format button ( "<code>&lt;/&gt;</code>").<br />
Anyway, it's seems that you are not that familiar with C++ and or OOP programming languages.</p>
<p dir="auto">There's a lot stuff going on in you code which is wrong.</p>
<ul>
<li>
<p dir="auto">The call to <code>Ui-&gt;cmbPorts....</code> in your <code>foreach</code> loop does not work like this, because your UI's namespace is named <code>Ui</code>, but not the pointer/instance to your actual compiled Ui class...</p>
</li>
<li>
<p dir="auto">And even then... you should only access the UI from the same class directly.<br />
You are in <code>serial.cpp</code>, while the <code>ui</code>, even if spelled correctly, is a private member of <code>MainWindow</code>. It cannot (and should not) be accessed from <code>serial</code>.</p>
</li>
<li>
<p dir="auto">Your <code>openPort()</code> method in <code>serial.cpp</code> is not even a member function of the <code>serial</code> class... it's just a globally declared function floating around in your <code>serial.cpp</code> file... which is another issue here...</p>
</li>
<li>
<p dir="auto">therefore the call <code>serial1.openPort()</code> doesn't work... because there is no <code>serial::openPort()</code>, as I explained above</p>
</li>
<li>
<p dir="auto">also your <code>serial</code> class is missing a constructor... we can't see your <code>serial</code> header, but since you are showing the code file, which contains no class/member functions at all, I doubt it's there.<br />
The error in your 3rd picture even says "undefined reference to serial::serial"</p>
</li>
</ul>
<p dir="auto">Might sound harsh, but I would recommend to learn the C++ basics (Objects, Pointers, Classes, Members, Inheritance and other OOP principles) and then come back before you dive further into Qt now, struggling with small things which are obligatory to work with Qt (and not get frustrated)</p>
<p dir="auto">So to answer your question "<code>Am I calling this method wrong?</code>", yes and a couple more mistakes</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/comedian">@<bdi>Comedian</bdi></a> are you more familiar with Python?!<br />
Have a look at the Python wrapper for Qt called "PySide"</p>
<p dir="auto">Here are some helpful links:</p>
<ul>
<li><a href="https://www.qt.io/qt-for-python" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.qt.io/qt-for-python</a></li>
<li><a href="https://doc.qt.io/qtforpython-6/" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qtforpython-6/</a></li>
<li><a href="https://wiki.qt.io/Qt_for_Python" target="_blank" rel="noopener noreferrer nofollow ugc">https://wiki.qt.io/Qt_for_Python</a></li>
</ul>
]]></description><link>https://forum.qt.io/post/812921</link><guid isPermaLink="true">https://forum.qt.io/post/812921</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Fri, 25 Oct 2024 02:33:53 GMT</pubDate></item></channel></rss>