<?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[Signal between 2 class]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I have 2 classes and I have to connect them with a signal</p>
<pre><code>A::A()
{
QListView *view=new QListView(this)
/*
..
*/
connect(view,&amp;QListView::clicked,this,[ ](){emit newSignal();});
};
B::B()
{
A *a=new A;
connect(a,&amp;A::newSignal,this,()[ ]{qDebug("test");});
}
</code></pre>
<p dir="auto">sorry for not post a complet code, he's long.<br />
Signal of QListView is works, but newSignal is not emited !<br />
Thanks for your help :)</p>
]]></description><link>https://forum.qt.io/topic/69440/signal-between-2-class</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 08:23:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/69440.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Jul 2016 19:16:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Signal between 2 class on Thu, 21 Jul 2016 22:16:48 GMT]]></title><description><![CDATA[<p dir="auto">Thanks !</p>
]]></description><link>https://forum.qt.io/post/338800</link><guid isPermaLink="true">https://forum.qt.io/post/338800</guid><dc:creator><![CDATA[Yacinoben]]></dc:creator><pubDate>Thu, 21 Jul 2016 22:16:48 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Thu, 21 Jul 2016 20:43:01 GMT]]></title><description><![CDATA[<p dir="auto">It's easier and shorter to just create it on the stack:</p>
<pre><code class="language-cpp">History history(this);
connect(&amp;history,&amp;History::selectHistory, this, [ ]{ qDebug("test"); } );
history.exec();
</code></pre>
]]></description><link>https://forum.qt.io/post/338784</link><guid isPermaLink="true">https://forum.qt.io/post/338784</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Thu, 21 Jul 2016 20:43:01 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Thu, 21 Jul 2016 17:44:08 GMT]]></title><description><![CDATA[<p dir="auto">Yes, you are right, when i call <strong>history</strong>, the object doesn't deletes, the use of the memory increases.<br />
but now,  its work !!</p>
<pre><code>   History *history=new History(this);
   history-&gt;setAttribute(Qt::WA_DeleteOnClose);
   connect(history,&amp;History::selectHistory,this,[ ] () {qDebug("test");});
   history-&gt;exec();
</code></pre>
<p dir="auto">Thank's</p>
]]></description><link>https://forum.qt.io/post/338772</link><guid isPermaLink="true">https://forum.qt.io/post/338772</guid><dc:creator><![CDATA[Yacinoben]]></dc:creator><pubDate>Thu, 21 Jul 2016 17:44:08 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Wed, 20 Jul 2016 21:16:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You're doing your connection after exec which means that it will happen after you close your <code>history</code> dialog thus you won't see any message.</p>
<p dir="auto">On a side note, you are leaking memory since you don't delete <code>history</code>. The objects will get destroyed when MainWindow is since you give it a parent but the memory will fill up more each time you call showHistory.</p>
]]></description><link>https://forum.qt.io/post/338629</link><guid isPermaLink="true">https://forum.qt.io/post/338629</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 20 Jul 2016 21:16:37 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Wed, 20 Jul 2016 11:35:13 GMT]]></title><description><![CDATA[<p dir="auto"><a href="http://easy-qt.blogspot.ru/2012/10/1.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://easy-qt.blogspot.ru/2012/10/1.html</a></p>
<p dir="auto">p.s. russian site</p>
]]></description><link>https://forum.qt.io/post/338535</link><guid isPermaLink="true">https://forum.qt.io/post/338535</guid><dc:creator><![CDATA[miho]]></dc:creator><pubDate>Wed, 20 Jul 2016 11:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Wed, 20 Jul 2016 11:34:28 GMT]]></title><description><![CDATA[<p dir="auto">It doesn't work .<br />
this is my code :</p>
<pre><code>class History : public QDialog
{
    Q_OBJECT
public:
    explicit History(QWidget *parent = 0);

signals:
    void selectHistory();
};

History::History(QWidget *parent) : QDialog(parent)
{
/*
...
*/
     connect(view,&amp;QListView::clicked,this,&amp;History::selectHistory);
}

void MainWindow::showHistory()
{
    History *history=new History(this);
    history-&gt;exec();
    connect(history,&amp;History::selectHistory,this,[ ] () {qDebug("test);});
}
</code></pre>
<p dir="auto">The QListView contains a history of browser, i would like when i click in a index, i open a new tab in my navigator with a fonction addTab in Mainwindow, but the signal doesn't work</p>
]]></description><link>https://forum.qt.io/post/338534</link><guid isPermaLink="true">https://forum.qt.io/post/338534</guid><dc:creator><![CDATA[Yacinoben]]></dc:creator><pubDate>Wed, 20 Jul 2016 11:34:28 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Wed, 20 Jul 2016 07:58:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yacinoben">@<bdi>Yacinoben</bdi></a><br />
Why using lambda in the first connect statement? You can directly connect signals with signals:</p>
<pre><code>connect(view, &amp;QListView::clicked, this, &amp;A::newSignal);
</code></pre>
]]></description><link>https://forum.qt.io/post/338484</link><guid isPermaLink="true">https://forum.qt.io/post/338484</guid><dc:creator><![CDATA[micland]]></dc:creator><pubDate>Wed, 20 Jul 2016 07:58:06 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Wed, 20 Jul 2016 07:28:38 GMT]]></title><description><![CDATA[<p dir="auto">connect(this-&gt;view,&amp;QListView::clicked, this,<a>[=]</a>{<br />
emit this-&gt;newSignal();<br />
});</p>
]]></description><link>https://forum.qt.io/post/338477</link><guid isPermaLink="true">https://forum.qt.io/post/338477</guid><dc:creator><![CDATA[praveen0991kr]]></dc:creator><pubDate>Wed, 20 Jul 2016 07:28:38 GMT</pubDate></item><item><title><![CDATA[Reply to Signal between 2 class on Tue, 19 Jul 2016 21:03:00 GMT]]></title><description><![CDATA[<p dir="auto">Please post the actual code. This won't even compile.<br />
<code>[ ](){emit newSignal();}</code> this lambda does not capture <code>this</code> so it would be a compilation error to try and call <code>newSignal()</code> from it.<br />
<code>()[ ]{qDebug("test");}</code> the parenthesis are all backwards.<br />
How and where is <code>newSignal</code> declared? Do you have a Q_OBJECT macro in you A class declaration?</p>
]]></description><link>https://forum.qt.io/post/338422</link><guid isPermaLink="true">https://forum.qt.io/post/338422</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Tue, 19 Jul 2016 21:03:00 GMT</pubDate></item></channel></rss>