<?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[[solved] newbie error :  signal NOT getting to slot!]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have a main window launching a child window, when the "start cpr" button is clicked on the child window, I want the main window to set up  a TCP Listening thread.  But I find, the signal does NOT get to the main window at all!</p>
<p dir="auto">The signal source is a push_button widget click.  I change the widget name on click, and then call the main window to set up listener.  The name change happens but the main window is not called.</p>
<p dir="auto">Can someone please spot the glaring error in what I am trying to do?</p>
<p dir="auto">@#ifndef MAINWINDOW_H<br />
#define MAINWINDOW_H</p>
<p dir="auto">#include &lt;QMainWindow&gt;<br />
#include &lt;QtWidgets&gt;<br />
#include "dynamicplots.h"<br />
#include "dispdata.h"<br />
#include "cprServer.h"</p>
<p dir="auto">namespace Ui {<br />
class MainWindow;<br />
}<br />
class dynamicPlots;<br />
class MainWindow : public QMainWindow<br />
{<br />
Q_OBJECT</p>
<p dir="auto">public:<br />
explicit MainWindow(QWidget <em>parent = 0);<br />
~MainWindow();<br />
void setPlotWindow(dynamicPlots</em> dp);</p>
<p dir="auto">private slots:<br />
void updatePeak(int val, int index);<br />
void on_quitButton_clicked();<br />
void slotAcceptUserLogin(QString&amp;,QString&amp;);<br />
void on_pbFiles_clicked();<br />
void setUpListener(bool);</p>
<p dir="auto">private:</p>
<pre><code>dynamicPlots *dPlot;
Ui::MainWindow *ui;
 dispData* rawData;
 cprServer* server;
 int newPeak;
 int newRecoil;
 int newRate;
 int newTime;
</code></pre>
<p dir="auto">};</p>
<p dir="auto">#endif // MAINWINDOW_H<br />
#ifndef DYNAMICPLOTS_H<br />
#define DYNAMICPLOTS_H</p>
<p dir="auto">#include &lt;QMainWindow&gt;<br />
#include "qcustomplot.h"<br />
namespace Ui {<br />
class dynamicPlots;<br />
}</p>
<p dir="auto">class dynamicPlots : public QMainWindow<br />
{<br />
Q_OBJECT</p>
<p dir="auto">public:<br />
explicit dynamicPlots(QWidget *parent = 0);<br />
~dynamicPlots();<br />
void plotRealTime(QCustomPlot *plotW);<br />
void updateDepth(int);<br />
void updatePeakGraph(int val, double index);<br />
void setRate(int rate);<br />
void updateRecoilGraph(int val,double index);<br />
void updateRateGraph(int val,double index);</p>
<p dir="auto">signals:<br />
void startCPR(bool);</p>
<p dir="auto">public slots:<br />
void updatePeakGraph(int val, int index);<br />
void on_pbCPR_clicked();<br />
// void realtimeDataSlot();</p>
<p dir="auto">//    void on_dial_valueChanged(int value);</p>
<p dir="auto">private slots:</p>
<p dir="auto">private:<br />
Ui::dynamicPlots *ui;<br />
QTimer dataTimer;<br />
};</p>
<p dir="auto">#endif // DYNAMICPLOTS_H<br />
#include "dynamicplots.h"<br />
#include "ui_dynamicplots.h"</p>
<p dir="auto">dynamicPlots::dynamicPlots(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::dynamicPlots)<br />
{<br />
ui-&gt;setupUi(this);<br />
plotRealTime(ui-&gt;plotW);<br />
ui-&gt;plotW-&gt;replot();</p>
<p dir="auto">}</p>
<p dir="auto">dynamicPlots::~dynamicPlots()<br />
{<br />
delete ui;<br />
}</p>
<p dir="auto">void dynamicPlots::updatePeakGraph(int val,int index)<br />
{<br />
double key = index/2000.0;</p>
<pre><code>static double lastPointKey = 0;
ui-&gt;plotW-&gt;graph(0)-&gt;addData(key,val);
ui-&gt;plotW-&gt;xAxis-&gt;setRange(key, 1.5, Qt::AlignRight);
ui-&gt;plotW-&gt;graph(0)-&gt;rescaleValueAxis();
ui-&gt;plotW-&gt;replot();
updateDepth(val);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void dynamicPlots::setRate(int rate)<br />
{<br />
ui-&gt;rateVal-&gt;setObjectName(QString::number(rate));<br />
}</p>
<p dir="auto">void dynamicPlots::on_pbCPR_clicked()<br />
{<br />
if (ui-&gt;pbCPR-&gt;text() == "Start CPR")<br />
{<br />
ui-&gt;pbCPR-&gt;setText("Finished CPR");<br />
qDebug()&lt;&lt;"Emitting Started CPR";<br />
bool start = true;</p>
<pre><code>    emit(startCPR(start));

}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
#include "cprserver.h"<br />
#include "logindialog.h"</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow)<br />
{<br />
const QString IP =     "127.0.0.1";<br />
const ushort port = 8100;<br />
ui-&gt;setupUi(this);<br />
rawData = new dispData (this);<br />
server = new cprServer(this,rawData,port);<br />
dPlot=new dynamicPlots(this);<br />
connect(rawData,SIGNAL(newPeakDepth(int,int)),this,SLOT(updatePeak(int, int)));<br />
connect(dPlot,SIGNAL(startCPR(bool)),this,SLOT(setUpListener(bool)));<br />
}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{<br />
delete ui;<br />
}<br />
void MainWindow::updatePeak(int val,int index)<br />
{<br />
newPeak=val;<br />
newTime=index;<br />
double time = newTime/2000.0;<br />
this-&gt;dPlot-&gt;updateDepth(newPeak);<br />
this-&gt;dPlot-&gt;updatePeakGraph(newPeak,time);</p>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::on_quitButton_clicked()<br />
{<br />
close();<br />
}</p>
<p dir="auto">void MainWindow::on_pbFiles_clicked()<br />
{<br />
LoginDialog* logDlg = new LoginDialog( this );<br />
connect( logDlg,<br />
SIGNAL(acceptLogin(QString&amp;,QString&amp;,int&amp;)),<br />
this,<br />
SLOT(slotAcceptUserLogin(QString&amp;,QString&amp;)));</p>
<pre><code>//setUpListener();
this-&gt;hide();
logDlg-&gt;show();
//dPlot-&gt;show();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::setUpListener(bool start)<br />
{<br />
const QString IP =     "127.0.0.1";<br />
const ushort port = 8100;<br />
QHostAddress host;<br />
qDebug()&lt;&lt;"Inside Set Up for Listening "&lt;&lt;start;<br />
host.setAddress(IP);<br />
//server-&gt;setRawData(rawData);<br />
if (!server-&gt;listen(host,port)) {<br />
QMessageBox::critical(this, tr("CPR Server"),<br />
tr("Unable to start the server: %1.")<br />
.arg(server-&gt;errorString()));<br />
close();<br />
//qDebug() &lt;&lt;  "Unable to start server" &lt;&lt; server.errorString();</p>
<pre><code>}
QString ipAddress=(server-&gt;serverAddress()).toString();
qDebug () &lt;&lt; "Server started at " &lt;&lt; ipAddress ;//go to log
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::setPlotWindow(dynamicPlots* dp)<br />
{<br />
qDebug() &lt;&lt;  "Setting up Plot Window";<br />
dPlot = dp;<br />
}@</p>
]]></description><link>https://forum.qt.io/topic/36796/solved-newbie-error-signal-not-getting-to-slot</link><generator>RSS for Node</generator><lastBuildDate>Fri, 30 Oct 2026 03:56:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/36796.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Jan 2014 09:19:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 15:09:14 GMT]]></title><description><![CDATA[<p dir="auto">Nice to read that your problem is solved.</p>
<p dir="auto">Please add [solved] to your title line of the initial post.</p>
]]></description><link>https://forum.qt.io/post/211513</link><guid isPermaLink="true">https://forum.qt.io/post/211513</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Mon, 20 Jan 2014 15:09:14 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 13:25:31 GMT]]></title><description><![CDATA[<p dir="auto">I believe you are right . I cleaned everything up - mini test cases I had added along the way, multiple debug statements to chk status of my TCP or embedded usb data etc... and now it runs just fine.  I had tried to set up things differently when I first started writing this code - every window is created in the main program and only has pointers to each other.  It is possibly I had some legacy in some class from the earlier set up.</p>
<p dir="auto">Now, every class I need for the execution of my code is set up via the MainWindow class.  Is this a good way to program though?</p>
<p dir="auto">Thanks so much for all your help!</p>
]]></description><link>https://forum.qt.io/post/211498</link><guid isPermaLink="true">https://forum.qt.io/post/211498</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 20 Jan 2014 13:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 13:13:38 GMT]]></title><description><![CDATA[<p dir="auto">You can use QObject's "dumpObjectInfo":<a href="http://qt-project.org/doc/qt-5/qobject.html#dumpObjectInfo" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qobject.html#dumpObjectInfo</a> and "dumpObjectTree":<a href="http://qt-project.org/doc/qt-5/qobject.html#dumpObjectTree" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qobject.html#dumpObjectTree</a> for more information. It tells you about connections and stuff.</p>
<p dir="auto">It looks like your connection is no longer active when you arrive there. I wonder if it has something to do with QMainWindow, but I might confuse something.</p>
]]></description><link>https://forum.qt.io/post/211495</link><guid isPermaLink="true">https://forum.qt.io/post/211495</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Mon, 20 Jan 2014 13:13:38 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 11:32:05 GMT]]></title><description><![CDATA[<p dir="auto">I am going a little nuts:<br />
@<br />
private:<br />
void setUpListener();<br />
Ui::MainWindow <em>ui;<br />
dynamicPlots <em>dPlot;<br />
dispData</em> rawData;<br />
cprServer</em> server;<br />
LoginDialog* logDlg;<br />
int newPeak;<br />
int newRecoil;<br />
int newRate;<br />
int newTime;<br />
};@</p>
<p dir="auto">signals from LoginDialog and dispData work fine!<br />
No action on signals from dynamicPlots!</p>
<p dir="auto">What could I be missing?!</p>
]]></description><link>https://forum.qt.io/post/211484</link><guid isPermaLink="true">https://forum.qt.io/post/211484</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 20 Jan 2014 11:32:05 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 11:00:00 GMT]]></title><description><![CDATA[<p dir="auto">I tried cleaning, setting breakpoints at the connect, emit and setUpListener lines:</p>
<p dir="auto">The debugger came out of the connect line with:<br />
returned value "2startCPR(bool)" char*</p>
<p dir="auto">Steeping into the emit signal functions goes to the MOC :<br />
@void dynamicPlots::startCPR(bool _t1)<br />
{<br />
void <em>_a[] = { 0, const_cast&lt;void</em>&gt;(reinterpret_cast&lt;const void*&gt;(&amp;_t1)) };<br />
QMetaObject::activate(this, &amp;staticMetaObject, 0, _a);<br />
}@</p>
<p dir="auto">Then, nothing happens.  It just waits!</p>
]]></description><link>https://forum.qt.io/post/211478</link><guid isPermaLink="true">https://forum.qt.io/post/211478</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 20 Jan 2014 11:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 10:32:49 GMT]]></title><description><![CDATA[<p dir="auto">You mean lines 130-132 are executed but emit on line 134 fails?<br />
The connect in line 154 is carried out, but slot line 194 with qDebug in line 198 fails to be executed?<br />
Did you do a rebuild?<br />
Also in the debugger to can set a break point at the emit and another one in the slot.<br />
Anyway a rebuild is recommended.</p>
]]></description><link>https://forum.qt.io/post/211473</link><guid isPermaLink="true">https://forum.qt.io/post/211473</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Mon, 20 Jan 2014 10:32:49 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 09:42:09 GMT]]></title><description><![CDATA[<p dir="auto">Assert does not fail, but still no action</p>
<p dir="auto">And thank you for including the &lt;cassert&gt;, I wondered how to add assert to qt before noticing your code in its entirety.</p>
]]></description><link>https://forum.qt.io/post/211464</link><guid isPermaLink="true">https://forum.qt.io/post/211464</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 20 Jan 2014 09:42:09 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] newbie error :  signal NOT getting to slot! on Mon, 20 Jan 2014 09:28:34 GMT]]></title><description><![CDATA[<p dir="auto">When you start the application in qt creator, it should tell you which connect is not established.<br />
Furthermore, by using connect's bool return value you can see which connect was not established. E.g.<br />
@<br />
#include &lt;cassert&gt;<br />
...</p>
<pre><code>bool boo = connect ( ptr1, SIGNAL(somesignal), ptr2, SLOT(someslot)));
assert ( boo );
</code></pre>
<p dir="auto">...<br />
@</p>
]]></description><link>https://forum.qt.io/post/211458</link><guid isPermaLink="true">https://forum.qt.io/post/211458</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Mon, 20 Jan 2014 09:28:34 GMT</pubDate></item></channel></rss>