<?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[QComboBox confusion]]></title><description><![CDATA[<p dir="auto">I am trying to implement a zoom select with QComboBox. Lets assume there are the following items in the combo box:<br />
25% -&gt; should lead to a signal setZoom(25)<br />
50% -&gt; should lead to a signal setZoom(50)<br />
100% -&gt; should lead to a signal setZoom(100)</p>
<p dir="auto">So far, so good. Now comes the challenge: The combo should be editable. When the user types 80 &lt;ENTER&gt;, a signal setZoom(80) should be emitted and the text in the combo should be set to "80%", but NO new item should be added to the drop down menu.</p>
<p dir="auto">I have fiddled with different events of QComboBox and the QLineEdit inside but I can't see how to do this. Any hints?</p>
<p dir="auto">Cheers,</p>
<p dir="auto">Eddy</p>
]]></description><link>https://forum.qt.io/topic/45056/qcombobox-confusion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Mar 2026 11:42:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/45056.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Aug 2014 09:53:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QComboBox confusion on Wed, 20 Aug 2014 11:06:06 GMT]]></title><description><![CDATA[<p dir="auto">Something like this should work:<br />
@<br />
ui-&gt;comboBox-&gt;setEditable(true);<br />
ui-&gt;comboBox-&gt;setInsertPolicy(QComboBox::NoInsert);</p>
<p dir="auto">connect(ui-&gt;comboBox, static_cast&lt;void (QComboBox::*)(int)&gt;(&amp;QComboBox::currentIndexChanged),<br />
[=](int index){<br />
emit setZoom(getZoomFromText(ui-&gt;comboBox-&gt;itemText(index)));<br />
});</p>
<p dir="auto">connect(ui-&gt;comboBox-&gt;lineEdit(), &amp;QLineEdit::returnPressed,<br />
<a>=</a>{<br />
emit setZoom(getZoomFromText(ui-&gt;comboBox-&gt;lineEdit()-&gt;text()));<br />
});<br />
@</p>
<p dir="auto"><em>Edit</em> ups, too slow :)</p>
]]></description><link>https://forum.qt.io/post/240547</link><guid isPermaLink="true">https://forum.qt.io/post/240547</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Wed, 20 Aug 2014 11:06:06 GMT</pubDate></item><item><title><![CDATA[Reply to QComboBox confusion on Wed, 20 Aug 2014 10:56:54 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Did you try setting "insertPolicy":<a href="http://qt-project.org/doc/qt-4.8/qcombobox.html#insertPolicy-prop" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/qcombobox.html#insertPolicy-prop</a> to QComboBox::NoInsert ?</p>
]]></description><link>https://forum.qt.io/post/240546</link><guid isPermaLink="true">https://forum.qt.io/post/240546</guid><dc:creator><![CDATA[p3c0]]></dc:creator><pubDate>Wed, 20 Aug 2014 10:56:54 GMT</pubDate></item></channel></rss>