<?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[Make LineEdit set focus for virtual keyboard]]></title><description><![CDATA[<p dir="auto">My goal is to create a simple virtual keyboard for my application without creating a separate window. I was able to create the keyboard but I am unable to press the button and display on whatever line edit (there's four in total) it is currently clicked on. I have been looking into how to create focus for a widget but I am completely lost.</p>
<p dir="auto">dialog.cpp</p>
<pre><code>#include "dialog.h"
#include "ui_dialog.h"
#include &lt;QKeyEvent&gt;
#include &lt;QSignalMapper&gt;
#include &lt;QInputMethod&gt;

Dialog::Dialog(QWidget *parent, Qt::WindowFlags flags) :
    QDialog(parent,flags),
    ui(new Ui::Dialog)
{
    ui-&gt;setupUi(this);
    signalMapper = new QSignalMapper(this);
    digitButtons = this-&gt;findChildren&lt;QPushButton *&gt;();
    for (int i=0;i&lt;digitButtons.count();i++)
    {
    connect(digitButtons.at(i), SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper-&gt;setMapping(digitButtons.at(i), i);
    }
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(btn_clicked(int)));
    QLineEdit::setFocusPolicy(Qt::ClickFocus);
}

void Dialog::btn_clicked(int btn)
{
QKeyEvent keyEvent(QEvent::KeyPress, 0, Qt::NoModifier, digitButtons.at(btn)-&gt;text(), false, 0);
QApplication::sendEvent(this-&gt;focusWidget(), &amp;keyEvent);
}

Dialog::~Dialog()
{
    delete ui;
}

</code></pre>
]]></description><link>https://forum.qt.io/topic/59906/make-lineedit-set-focus-for-virtual-keyboard</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 07:33:29 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/59906.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Oct 2015 21:23:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Tue, 27 Oct 2015 23:36:05 GMT]]></title><description><![CDATA[<p dir="auto">That makes it easier to do the input properly.</p>
]]></description><link>https://forum.qt.io/post/295390</link><guid isPermaLink="true">https://forum.qt.io/post/295390</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 27 Oct 2015 23:36:05 GMT</pubDate></item><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Wed, 21 Oct 2015 23:21:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> These articles semi helped. Both looked like those virtual keyboards are used as a plugin so that they appear once the user clicks on the textfield/lineedit. However, i would like my keyboard to be a widget that i could add to a layout and be inside the application I am creating. Is the QPlatformInputContext()  necessary for this??</p>
]]></description><link>https://forum.qt.io/post/294699</link><guid isPermaLink="true">https://forum.qt.io/post/294699</guid><dc:creator><![CDATA[marlenet15]]></dc:creator><pubDate>Wed, 21 Oct 2015 23:21:21 GMT</pubDate></item><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Wed, 21 Oct 2015 20:33:51 GMT]]></title><description><![CDATA[<p dir="auto">They are using DBus which doesn't require any internet connection but no you can use other methods</p>
]]></description><link>https://forum.qt.io/post/294677</link><guid isPermaLink="true">https://forum.qt.io/post/294677</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 21 Oct 2015 20:33:51 GMT</pubDate></item><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Wed, 21 Oct 2015 18:02:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> I was reading <a href="http://www.kdab.com/qt-input-method-virtual-keyboard/" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.kdab.com/qt-input-method-virtual-keyboard/</a> and I thought it gave a great explanation of the code but they are using a server for the QT Input Method Plugin. Is this really necessary? What if I am not connected to the internet when running the application?</p>
]]></description><link>https://forum.qt.io/post/294654</link><guid isPermaLink="true">https://forum.qt.io/post/294654</guid><dc:creator><![CDATA[marlenet15]]></dc:creator><pubDate>Wed, 21 Oct 2015 18:02:25 GMT</pubDate></item><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Tue, 20 Oct 2015 21:46:56 GMT]]></title><description><![CDATA[<p dir="auto">You have a pretty good article <a href="http://tolszak-dev.blogspot.ch/2013/04/qplatforminputcontext-and-virtual.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a> about it or <a href="http://www.kdab.com/qt-input-method-virtual-keyboard/" target="_blank" rel="noopener noreferrer nofollow ugc">here</a></p>
]]></description><link>https://forum.qt.io/post/294497</link><guid isPermaLink="true">https://forum.qt.io/post/294497</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 20 Oct 2015 21:46:56 GMT</pubDate></item><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Tue, 20 Oct 2015 21:43:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> how would I implement my own QInputMethod?</p>
]]></description><link>https://forum.qt.io/post/294495</link><guid isPermaLink="true">https://forum.qt.io/post/294495</guid><dc:creator><![CDATA[marlenet15]]></dc:creator><pubDate>Tue, 20 Oct 2015 21:43:54 GMT</pubDate></item><item><title><![CDATA[Reply to Make LineEdit set focus for virtual keyboard on Tue, 20 Oct 2015 21:36:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You won't be able to do it purely with focus. If you don't want to implement your own QInputMethod, you'd rather have to give your keyboard the information about which QLineEdit it should write in</p>
]]></description><link>https://forum.qt.io/post/294494</link><guid isPermaLink="true">https://forum.qt.io/post/294494</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 20 Oct 2015 21:36:04 GMT</pubDate></item></channel></rss>