<?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[comboBox with Qt::Alignement as itemData]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">i have a comboBox filled like this:</p>
<pre><code>ui-&gt;comboBoxPos-&gt;addItem( "Top Left", (int)(Qt::AlignTop | Qt::AlignLeft) );
ui-&gt;comboBoxPos-&gt;addItem( "Top Centered", (int)(Qt::AlignTop | Qt::AlignHCenter) );
ui-&gt;comboBoxPos-&gt;addItem( "Top Right", (int)(Qt::AlignTop | Qt::AlignRight) );
</code></pre>
<p dir="auto">or this</p>
<pre><code>ui-&gt;comboBoxPos-&gt;addItem( "Top Left", 33 );
ui-&gt;comboBoxPos-&gt;addItem( "Top Centered", 36 );
ui-&gt;comboBoxPos-&gt;addItem( "Top Right", 34 );
</code></pre>
<p dir="auto">With</p>
<p dir="auto">void MainWindow::on_comboBoxPos_currentIndexChanged(int index)<br />
{<br />
qDebug() &lt;&lt; Q_FUNC_INFO &lt;&lt;  ui-&gt;comboBoxPos-&gt;itemData(index).toInt();<br />
}</p>
<p dir="auto">I never get back the itemData? What i'm doing wrong?<br />
Thx</p>
]]></description><link>https://forum.qt.io/topic/55503/combobox-with-qt-alignement-as-itemdata</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 14:56:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/55503.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Jun 2015 14:02:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to comboBox with Qt::Alignement as itemData on Mon, 22 Jun 2015 14:05:27 GMT]]></title><description><![CDATA[<p dir="auto">i found a solution:</p>
<p dir="auto">fill comBox with QStringList _PlotAlignMents and QList&lt;qint32&gt; _PlotAlignmentsData:</p>
<pre><code>_PlotAlignments &lt;&lt; tr("Top Left")       &lt;&lt; tr("Top Centered")       &lt;&lt; tr("Top Right")
                &lt;&lt; tr("Centered Left")  &lt;&lt; tr("Centered Centered")  &lt;&lt; tr("Centered Right")
                &lt;&lt; tr("Bottom Left")    &lt;&lt; tr("Bottom Centered")    &lt;&lt; tr("Bottom Right");
ui-&gt;comboBoxAlignment-&gt;addItems( _PlotAlignments );
_PlotAlignmentsData &lt;&lt; (int)(Qt::AlignTop | Qt::AlignLeft)
                    &lt;&lt; (int)(Qt::AlignTop | Qt::AlignHCenter)
                    &lt;&lt; (int)(Qt::AlignTop | Qt::AlignRight)
                    &lt;&lt; (int)(Qt::AlignVCenter | Qt::AlignLeft)
                    &lt;&lt; (int)(Qt::AlignVCenter | Qt::AlignHCenter)
                    &lt;&lt; (int)(Qt::AlignVCenter | Qt::AlignRight)
                    &lt;&lt; (int)(Qt::AlignBottom | Qt::AlignLeft)
                    &lt;&lt; (int)(Qt::AlignBottom | Qt::AlignHCenter)
                    &lt;&lt; (int)(Qt::AlignBottom | Qt::AlignRight);
for(int i=0; i&lt;_PlotAlignmentsData.size(); i++)
    ui-&gt;comboBoxAlignment-&gt;setItemData(i,_PlotAlignmentsData[i]);
</code></pre>
<p dir="auto">now i can get the data:</p>
<p dir="auto">void ui_plot_settings::on_comboBoxAlignment_currentIndexChanged(int index)<br />
{<br />
qDebug() &lt;&lt; Q_FUNC_INFO &lt;&lt; ui-&gt;comboBoxAlignment-&gt;itemData(index).toInt();<br />
}</p>
<p dir="auto">This works now.</p>
]]></description><link>https://forum.qt.io/post/279180</link><guid isPermaLink="true">https://forum.qt.io/post/279180</guid><dc:creator><![CDATA[HappyCoder]]></dc:creator><pubDate>Mon, 22 Jun 2015 14:05:27 GMT</pubDate></item><item><title><![CDATA[Reply to comboBox with Qt::Alignement as itemData on Mon, 22 Jun 2015 05:56:30 GMT]]></title><description><![CDATA[<p dir="auto">yes, if i use the signal currentIndexChanged(QString). But i thought that for the first index (int)(Qt::AlignTop | Qt::AlignLeft) is the<br />
data to that item and is stored as QVariant. I think i will make a switch case on the index, that is working.</p>
]]></description><link>https://forum.qt.io/post/279116</link><guid isPermaLink="true">https://forum.qt.io/post/279116</guid><dc:creator><![CDATA[HappyCoder]]></dc:creator><pubDate>Mon, 22 Jun 2015 05:56:30 GMT</pubDate></item><item><title><![CDATA[Reply to comboBox with Qt::Alignement as itemData on Sun, 21 Jun 2015 14:33:20 GMT]]></title><description><![CDATA[<p dir="auto">Do you get the proper text (e.g. "Top Left") back?</p>
]]></description><link>https://forum.qt.io/post/279020</link><guid isPermaLink="true">https://forum.qt.io/post/279020</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Sun, 21 Jun 2015 14:33:20 GMT</pubDate></item></channel></rss>