<?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[Try to emit signal in keyPressEvent]]></title><description><![CDATA[<p dir="auto">Hi. Why do I have errors? What is my mistake?<br />
The first in constructor: undefined reference to `vtable for LineEditClickedButton;<br />
And others in keyPressEvent: undefined reference to LineEditClickedButton::buttonPressed</p>
<pre><code>#include &lt;QLineEdit&gt;

class LineEditClickedButton : public QLineEdit
{
    Q_OBJECT
public:
    explicit LineEditClickedButton(QWidget *parent = nullptr);

protected:
    void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;

signals:
    void buttonPressed(QString button);
};
</code></pre>
<pre><code>#include "lineeditclickedbutton.h"
#include &lt;QKeyEvent&gt;

LineEditClickedButton::LineEditClickedButton(QWidget *parent) :
    QLineEdit(parent)
{}

void LineEditClickedButton::keyPressEvent(QKeyEvent *e)
{
    switch (e-&gt;key()) {
    case Qt::Key_Escape:
        emit buttonPressed("esc");
        break;
    case Qt::Key_Tab:
        emit buttonPressed("tab");
        break;
    }
    QLineEdit::keyPressEvent(e);
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/126768/try-to-emit-signal-in-keypressevent</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 21:42:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/126768.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 May 2021 18:05:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Try to emit signal in keyPressEvent on Tue, 18 May 2021 19:14:20 GMT]]></title><description><![CDATA[<p dir="auto">Besides what <a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said, is this in a library?</p>
<p dir="auto">Also a piece of advice stick to <code>const &lt;Type&gt; &amp;</code> for signal types.</p>
]]></description><link>https://forum.qt.io/post/660383</link><guid isPermaLink="true">https://forum.qt.io/post/660383</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Tue, 18 May 2021 19:14:20 GMT</pubDate></item><item><title><![CDATA[Reply to Try to emit signal in keyPressEvent on Tue, 18 May 2021 18:23:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/evgeny-siberia">@<bdi>Evgeny-Siberia</bdi></a><br />
Since I can't spot anything: have you cleaned out all intermeditae files in the compilation output directory and rebuilt?  Especially if you have recently added the <code>Q_OBJECT</code>.  At least make sure the error remains.</p>
]]></description><link>https://forum.qt.io/post/660372</link><guid isPermaLink="true">https://forum.qt.io/post/660372</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 18 May 2021 18:23:08 GMT</pubDate></item></channel></rss>