<?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[Catch a signal from a parent class and send your own same named signal?]]></title><description><![CDATA[<p dir="auto">Hey there everybody, I'm new to this community!<br />
I did a lot of research, but haven't found any help or similar problems.</p>
<p dir="auto">First of all I'm gonna try to give you a short explanation:</p>
<p dir="auto">I wrote my own class, called ComboTable, which inherits QComboBox. Its' aim is to be a QComboBox with a QTableView, instead of a QListView. Because I wanna simply replace QComboBox widgets in a pretty big software (without rewriting parts of it) there are some functions I had to overwrite, which worked out pretty good. The main problem seems to be the calculation of the items' index. QComboBox just returns QModelIndex::row(), which does not work for me, because I got columns, too.</p>
<p dir="auto">And that's where my bigger problems start:</p>
<p dir="auto">There are some signals, using the index (e.g. activated ( int ) )<br />
QComboBox returns the activated items' row.</p>
<p dir="auto">My (dismissed) ideas:</p>
<p dir="auto">I don't want to implement an own (other named) signal, because (as I wrote a few lines ago) I wanna replace QComboBox Widgets without changing the softwares' code. Another problem is, that I cannot set a signal private, so you could use a not working signal, which is no option to me.</p>
<p dir="auto">Overwriting activated ( int ), catching activated ( QString ) and giving out activated ( int )  with the recalculated index, does not work, because there could be more than one item using the same QString.</p>
<p dir="auto">My last idea was to write my own signal activated ( int ), catch the parent class' activated(int) and connect it to a function which emits my own activated ( int ) with the right index.</p>
<p dir="auto">@QComboBox <em>pBox = dynamic_cast &lt;QComboBox</em>&gt; (this);@</p>
<p dir="auto">DID NOT WORK! :(</p>
<p dir="auto">Here is my simplified code:</p>
<p dir="auto">@<a href="//combotable.cpp" target="_blank" rel="noopener noreferrer nofollow ugc">//combotable.cpp</a></p>
<p dir="auto">ComboTable::ComboTable(QWidget *parent) :<br />
QComboBox(parent)<br />
{<br />
view = new QTableView();<br />
updateTable();<br />
this-&gt;setView(view);<br />
view-&gt;horizontalHeader()-&gt;hide();<br />
view-&gt;verticalHeader()-&gt;hide();<br />
view-&gt;setSelectionMode(QAbstractItemView::SingleSelection);</p>
<pre><code>actLock=false;

QComboBox *pBox = dynamic_cast &lt;QComboBox*&gt; (this);   


connect( pBox, SIGNAL(activated(int)), this, SLOT(emitActivated()));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::emitActivated()<br />
{</p>
<pre><code>if(actLock)
    return;
actLock=true;

qDebug() &lt;&lt; "TEXT" &lt;&lt; currentText() &lt;&lt; endl;


emit activated(currentText());
emit activated(currentIndex());

actLock=false;
</code></pre>
<p dir="auto">}</p>
<p dir="auto"><a href="//combotable.h" target="_blank" rel="noopener noreferrer nofollow ugc">//combotable.h</a></p>
<p dir="auto">class ComboTable : public QComboBox<br />
{<br />
Q_OBJECT<br />
public:</p>
<pre><code>explicit ComboTable(QWidget *parent = 0);
</code></pre>
<p dir="auto">signals:</p>
<pre><code>void itemsEdited();
void activated ( int index );
</code></pre>
<p dir="auto">void activated ( QString text )</p>
<p dir="auto">protected:</p>
<pre><code>void wheelEvent(QWheelEvent *e);
</code></pre>
<p dir="auto">//    void _q_emitCurrentIndexChanged(const QModelIndex &amp;index);<br />
//    void _q_emitHighlighted(const QModelIndex &amp;index);</p>
<p dir="auto">protected slots:</p>
<pre><code>void emitActivated();
</code></pre>
<p dir="auto">private:</p>
<pre><code>static QList &lt;Item&gt; items;
QTableView *view;
int columns;
bool returnZero;
QModelIndex currentIndex_;
TableModel *model;
QLineEdit *line;
void insertSeparator(int index){}
bool actLock;
</code></pre>
<p dir="auto">}; @</p>
<p dir="auto">Is there any chance to handle the parent class' signal and my own (same named) signal on each own?</p>
<p dir="auto">Thank you for thinking about my problem and your ideas in front! :)</p>
<p dir="auto">Steff</p>
]]></description><link>https://forum.qt.io/topic/1276/catch-a-signal-from-a-parent-class-and-send-your-own-same-named-signal</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 12:32:56 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/1276.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Oct 2010 10:21:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Wed, 17 Nov 2010 11:47:31 GMT]]></title><description><![CDATA[<p dir="auto">bq. You can use QCompleter to provide auto completions in any Qt widget, such as QLineEdit and QComboBox. When the user starts typing a word, QCompleter suggests possible ways of completing the word, based on a word list.</p>
<p dir="auto">Sounds like something different! :-/</p>
<p dir="auto">I'm gonna try Franzk solution. I think I can keep a lot of Code.</p>
<p dir="auto">The only thing i don't know how to deal with are Events.<br />
How can I ignore QComboBox's (e.g.) wheel event?</p>
<p dir="auto">EDIT : SORRY, found it myself. Using an EventHandler is the right solution! :)</p>
]]></description><link>https://forum.qt.io/post/60145</link><guid isPermaLink="true">https://forum.qt.io/post/60145</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 17 Nov 2010 11:47:31 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Tue, 26 Oct 2010 21:33:38 GMT]]></title><description><![CDATA[<p dir="auto">If you want to use the QTableView with QComboBox, isn't that possible with the QCompleter? I have used that with QLineEdit a lot, and it works fine with tables. Take a look to QComboBox::setCompleter(..).</p>
]]></description><link>https://forum.qt.io/post/58712</link><guid isPermaLink="true">https://forum.qt.io/post/58712</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 26 Oct 2010 21:33:38 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Mon, 25 Oct 2010 14:12:16 GMT]]></title><description><![CDATA[<p dir="auto">I haven't been looking into this code specifically, but it is possibly not a good idea to declare and emit signals that have the same name and signature as a signal that is available in one of the parent classes. Signals are protected functions and you will obscure these if you follow this path. Also, the connect() function <em>always</em> takes QObject as arguments, so there is no telling what will happen. (It will probably connect to the QComboBox signals.)</p>
<p dir="auto">If you insist on keeping these signal names, you could consider wrapping the QComboBox up into a widget of your own and propagating most of the useful interface. It will be more predictable what is going to happen.</p>
<p dir="auto">So consider:<br />
@ class MyWidget : public QWidget<br />
{<br />
Q_OBJECT<br />
public:</p>
<pre><code>...
</code></pre>
<p dir="auto">signals:<br />
void activated(int);<br />
void activated(QString);</p>
<p dir="auto">private:<br />
QComboBox *combo;<br />
};@</p>
<p dir="auto">instead of<br />
@ class MyCombo : public QComboBox<br />
{<br />
Q_OBJECT<br />
public:<br />
...<br />
signals:<br />
void activated(int);<br />
void activated(QString);<br />
};@</p>
<p dir="auto">You'll loose the polymorphism to a QComboBox. If you don't want that, get some different names for your signals.</p>
]]></description><link>https://forum.qt.io/post/58590</link><guid isPermaLink="true">https://forum.qt.io/post/58590</guid><dc:creator><![CDATA[Franzk]]></dc:creator><pubDate>Mon, 25 Oct 2010 14:12:16 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Mon, 25 Oct 2010 09:12:53 GMT]]></title><description><![CDATA[<p dir="auto">@</p>
<p dir="auto">// combotable.cpp PART 2</p>
<p dir="auto">QVariant ComboTable::itemData(int index, int role) const<br />
{<br />
if(<a href="http://items.at" target="_blank" rel="noopener noreferrer nofollow ugc">items.at</a>(index).userData.isValid() &amp;&amp; role ==Qt::DisplayRole)<br />
return <a href="http://items.at" target="_blank" rel="noopener noreferrer nofollow ugc">items.at</a>(currentIndex()).text;</p>
<pre><code>if(items.at(index).userData.isValid() &amp;&amp; role ==Qt::DecorationRole)
    return items.at(currentIndex()).icon;

if(items.at(index).userData.isValid() &amp;&amp; role ==Qt::UserRole)
    return items.at(currentIndex()).userData;

return QVariant::Invalid;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::setItemData(int index, const QVariant &amp; value, int role)<br />
{<br />
if (value.isValid() &amp;&amp; role == Qt::DisplayRole )<br />
items[index].text= value.toString();</p>
<pre><code>if (value.isValid() &amp;&amp; role == Qt::DecorationRole)
    items[index].icon= value.value&lt;QIcon&gt;();

if (value.isValid() &amp;&amp; role == Qt::UserRole )
    items[index].userData= value;

return;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::clear()<br />
{<br />
items.clear();<br />
emit itemsEdited();<br />
}</p>
<p dir="auto">void ComboTable::setCurrentIndex(int index)<br />
{<br />
int rowTmp=floor(index/columns);<br />
int colTmp=index%columns;</p>
<pre><code>QModelIndex mi = model-&gt;index(rowTmp, colTmp);

view-&gt;selectionModel()-&gt;setCurrentIndex(mi,QItemSelectionModel::SelectCurrent);
this-&gt;setModelColumn(colTmp);
QComboBox::setCurrentIndex(rowTmp);

emit currentIndexChanged (index);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">QIcon ComboTable::itemIcon (int index) const<br />
{<br />
return <a href="http://items.at" target="_blank" rel="noopener noreferrer nofollow ugc">items.at</a>(index).icon;<br />
}</p>
<p dir="auto">void ComboTable::setItemIcon(int index, const QIcon &amp;icon)<br />
{<br />
items[index].icon=icon;<br />
}</p>
<p dir="auto">QString ComboTable::itemText(int index) const<br />
{<br />
return <a href="http://items.at" target="_blank" rel="noopener noreferrer nofollow ugc">items.at</a>(index).text;<br />
}</p>
<p dir="auto">void ComboTable::setItemText(int index, const QString &amp;text)<br />
{<br />
items[index].text=text;<br />
}</p>
<p dir="auto">int ComboTable::findData(const QVariant &amp;data, int role, Qt::MatchFlags flags) const<br />
{<br />
QModelIndexList result;</p>
<pre><code>for(int i=0; i&lt;columns; i++)
{
    QModelIndex start = model-&gt;index(0,i);
    result.append(model-&gt;match(start, role, data, 1, flags));
}

if (result.isEmpty())
    return -1;
return result.first().row()*columns+result.first().column();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">int ComboTable::findText(const QString &amp;text,Qt::MatchFlags flags) const<br />
{<br />
QVariant data = text;<br />
return findData(data,Qt::DisplayRole,flags);<br />
}</p>
<p dir="auto">void ComboTable::wheelEvent(QWheelEvent *e)<br />
{</p>
<pre><code>int newIndex = currentIndex();

    if (e-&gt;delta() &gt; 0)
        newIndex--;

     else
        newIndex++;

    if((newIndex&lt;items.length()) &amp;&amp; newIndex &gt;= 0)
     {
        setCurrentIndex(newIndex);
        emit activated(currentIndex());
</code></pre>
<p dir="auto">//            emit activated(currentText());<br />
}</p>
<pre><code>    e-&gt;accept();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::emitActivated()<br />
{<br />
qDebug() &lt;&lt; "TEXT before lock" &lt;&lt; currentText() &lt;&lt; " l: " &lt;&lt; actLock &lt;&lt; endl;</p>
<pre><code>if(actLock)
    return;
actLock=true;

qDebug() &lt;&lt; "TEXT" &lt;&lt; currentText() &lt;&lt; endl;
</code></pre>
<p dir="auto">//    emit activated(currentText());<br />
emit activated(currentIndex());</p>
<pre><code>actLock=false;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::_q_emitCurrentIndexChanged(const QModelIndex &amp;index)<br />
{<br />
if (!index.isValid())<br />
return;</p>
<pre><code>QString text(index.data().toString());
emit currentIndexChanged(index.row()*columns+index.column());
emit currentIndexChanged(text);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::_q_emitHighlighted(const QModelIndex &amp;index)<br />
{<br />
if (!index.isValid())<br />
return;</p>
<pre><code>QString text(index.data().toString());
emit highlighted(index.row()*columns+index.column());
emit highlighted(text);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::shout(int index)<br />
{<br />
qDebug() &lt;&lt; "SHOUT" &lt;&lt; <a href="http://items.at" target="_blank" rel="noopener noreferrer nofollow ugc">items.at</a>(index).text &lt;&lt; endl ;<br />
}</p>
<p dir="auto">void ComboTable::shout(const QString&amp; text)<br />
{<br />
qDebug() &lt;&lt; "SHOUT TEXT" &lt;&lt; text&lt;&lt; endl ;<br />
}</p>
<p dir="auto">@</p>
]]></description><link>https://forum.qt.io/post/58556</link><guid isPermaLink="true">https://forum.qt.io/post/58556</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 25 Oct 2010 09:12:53 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Mon, 25 Oct 2010 09:12:33 GMT]]></title><description><![CDATA[<p dir="auto">@</p>
<p dir="auto"><a href="//combotable.cpp" target="_blank" rel="noopener noreferrer nofollow ugc">//combotable.cpp</a> PART 1</p>
<p dir="auto">#include "combotable.h"<br />
#include &lt;QTableView&gt;<br />
#include &lt;QComboBox&gt;<br />
#include &lt;QTableView&gt;<br />
#include &lt;QHeaderView&gt;<br />
#include &lt;QVariant&gt;<br />
#include &lt;QDebug&gt;<br />
#include &lt;math.h&gt;<br />
#include &lt;QPushButton&gt;<br />
#include &lt;QGridLayout&gt;<br />
#include &lt;QLineEdit&gt;<br />
#include &lt;QWheelEvent&gt;</p>
<p dir="auto">//----------------------------------TableModel----------------------------------------------------</p>
<p dir="auto">QVariant TableModel::data(const QModelIndex&amp; index, int role) const<br />
{</p>
<pre><code>if (index.isValid() &amp;&amp; role == Qt::DecorationRole &amp;&amp; index.row()*cols+index.column()&lt; ComboTable::getItems().length())
    {
       return QIcon(ComboTable::getItems().at(index.row()*cols+index.column()).icon);
        qDebug() &lt;&lt; "Icon";
    }

if (index.isValid() &amp;&amp; role == Qt::DisplayRole &amp;&amp; index.row()*cols+index.column()&lt; ComboTable::getItems().length())
{
   return QString(ComboTable::getItems().at(index.row()*cols+index.column()).text);
    qDebug() &lt;&lt; "Text";
}

if (index.isValid() &amp;&amp; role == Qt::UserRole &amp;&amp; index.row()*cols+index.column()&lt; ComboTable::getItems().length())
{
   return QVariant(ComboTable::getItems().at(index.row()*cols+index.column()).userData);
   qDebug() &lt;&lt; "UserData";
}



return QVariant();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">//-----------------------------ComboTable--------------------------------------</p>
<p dir="auto">QList &lt;Item&gt; ComboTable::items;</p>
<p dir="auto">ComboTable::ComboTable(QWidget *parent) :<br />
QComboBox(parent)<br />
{<br />
view = new QTableView();<br />
updateTable();<br />
this-&gt;setView(view);<br />
view-&gt;horizontalHeader()-&gt;hide();<br />
view-&gt;verticalHeader()-&gt;hide();<br />
view-&gt;setSelectionMode(QAbstractItemView::SingleSelection);</p>
<pre><code>QPushButton *btn = new QPushButton();
btn-&gt;show();

actLock=false;

QComboBox *pBox = dynamic_cast &lt;QComboBox*&gt; (this);

connect( btn, SIGNAL(clicked()), this, SLOT(giveOut()) );
connect( pBox, SIGNAL(activated(int)), this, SLOT(emitActivated()));
connect(this,SIGNAL(activated(int)),this,SLOT(shout(int)));
connect(this,SIGNAL(itemsEdited()),this,SLOT(updateTable()));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::insertItem(int index, const QString &amp;text, const QVariant &amp;userData)<br />
{<br />
Item item;<br />
item.text=text;</p>
<pre><code>if(userData.isValid())
item.userData=userData;

items.insert(index,item);
emit itemsEdited();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::insertItem(int index,const QIcon &amp; icon, const QString &amp;text, const QVariant &amp;userData)<br />
{<br />
Item item;<br />
item.text=text;<br />
item.icon=icon;</p>
<pre><code>if(userData.isValid())
item.userData=userData;

items.insert(index,item);
emit itemsEdited();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::insertItems(int index, const QList &lt;QString&gt; &amp;list)<br />
{<br />
for(int i=0; i&lt; list.length(); i++)<br />
{<br />
Item item;<br />
<a href="http://item.text=list.at" target="_blank" rel="noopener noreferrer nofollow ugc">item.text=list.at</a>(i);<br />
items.insert(index+i,item);<br />
}</p>
<pre><code>emit itemsEdited();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">Item&amp; ComboTable::getItem(int index)<br />
{<br />
if(index&gt;items.length()-1)<br />
{<br />
Item emptyItem;<br />
return emptyItem;<br />
}<br />
else<br />
return items[index];<br />
}</p>
<p dir="auto">void ComboTable::addItem(const QString &amp;text, const QVariant &amp;userData)<br />
{<br />
Item item;<br />
item.text=text;</p>
<pre><code>if(userData.isValid())
item.userData=userData;

items.append(item);
emit itemsEdited();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::addItem(const QIcon &amp; icon, const QString &amp; text, const QVariant &amp; userData)<br />
{<br />
Item item;<br />
item.text=text;</p>
<pre><code>item.icon=icon;

if(userData.isValid())
item.userData=userData;

items.append(item);
emit itemsEdited();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::addItems(const QList &lt;QString&gt; &amp;list)<br />
{<br />
for(int i=0; i&lt; list.length(); i++)<br />
{<br />
Item item;<br />
<a href="http://item.text=list.at" target="_blank" rel="noopener noreferrer nofollow ugc">item.text=list.at</a>(i);<br />
items.append(item);<br />
}<br />
emit itemsEdited();<br />
}</p>
<p dir="auto">void ComboTable::removeItem(int index)<br />
{<br />
items.removeAt(index);<br />
emit itemsEdited();<br />
}</p>
<p dir="auto">void ComboTable::updateTable()<br />
{<br />
int tableWidth=0;</p>
<pre><code>int size(ceil(sqrt(items.length())));
qDebug() &lt;&lt; "Length and SIZE SQRT" &lt;&lt; items.length() &lt;&lt; "and" &lt;&lt; size &lt;&lt; endl;

model = new TableModel(size,size, this);
columns = size;

this-&gt;setModel(model);

for(int i=0; i&lt;size;i++)
{
    tableWidth += view-&gt;columnWidth(i);
    qDebug() &lt;&lt; "ColumWidth" &lt;&lt; view-&gt;columnWidth(i);
}

qDebug() &lt;&lt; "TABLEWIDTH" &lt;&lt; tableWidth &lt;&lt; endl;
view-&gt;setMinimumWidth(tableWidth);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::setColumnWidth ( int column, int width )<br />
{<br />
view-&gt;setColumnWidth(column,width);<br />
emit itemsEdited();<br />
}</p>
<p dir="auto">void ComboTable::setRowHeight ( int row, int height )<br />
{<br />
view-&gt;setRowHeight (row,height);<br />
emit itemsEdited();<br />
}</p>
<p dir="auto">int ComboTable::count()<br />
{<br />
return items.length();<br />
}</p>
<p dir="auto">QList &lt;QString&gt; ComboTable::toString()<br />
{<br />
QList &lt;QString&gt; list;</p>
<pre><code>for (int i=0; i&lt;items.length(); i++)
{
    list.append(items.at(i).text);
}

return list;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void ComboTable::giveOut() //------------Tests currentText and currentIndex functions--------------------<br />
{<br />
qDebug() &lt;&lt; "GIVEOUT" &lt;&lt; this-&gt;currentText() &lt;&lt; "INDEX"&lt;&lt; this-&gt;currentIndex();<br />
}</p>
<p dir="auto">int ComboTable::currentIndex() const<br />
{<br />
if(view-&gt;selectionModel()-&gt;currentIndex().column()== -1)<br />
return 0;</p>
<pre><code>int ret = view-&gt;selectionModel()-&gt;currentIndex().row()*columns+view-&gt;selectionModel()-&gt;currentIndex().column();
return ret;
</code></pre>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/post/58554</link><guid isPermaLink="true">https://forum.qt.io/post/58554</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 25 Oct 2010 09:12:33 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Mon, 25 Oct 2010 09:09:47 GMT]]></title><description><![CDATA[<p dir="auto">The code is pretty long, that's why I didn't post it.<br />
I can only post 6000 characters, the whole code got about 12000.</p>
<p dir="auto">It's not about a bug I wanna fix, it's about a basic problem I don't know how to handle.</p>
<p dir="auto">@</p>
<p dir="auto"><a href="//combotable.h" target="_blank" rel="noopener noreferrer nofollow ugc">//combotable.h</a></p>
<p dir="auto">#ifndef COMBOTABLE_H<br />
#define COMBOTABLE_H</p>
<p dir="auto">#include &lt;QWidget&gt;<br />
#include &lt;QComboBox&gt;<br />
#include &lt;QAbstractTableModel&gt;<br />
#include "combotable.h"<br />
#include &lt;QDebug&gt;<br />
#include &lt;QTableView&gt;<br />
#include &lt;QLabel&gt;</p>
<p dir="auto">struct Item {QIcon icon; QString text;QVariant userData;};<br />
class TableModel;<br />
class QAbstractItemView;<br />
class QLineEdit;<br />
class QComboBoxPrivate;<br />
class QCompleter;</p>
<p dir="auto">//---------------Combo Table--------------------------------</p>
<p dir="auto">class ComboTable : public QComboBox<br />
{<br />
Q_OBJECT<br />
public:</p>
<pre><code>explicit ComboTable(QWidget *parent = 0);

void addItem(const QString &amp;text, const QVariant &amp;userData = QVariant());
void addItem(const QIcon &amp; icon, const QString &amp; text, const QVariant &amp; userData = QVariant());
void addItems(const QList&lt;QString&gt; &amp;list);
int  count();
int currentIndex() const;
int findData(const QVariant &amp;data, int role = Qt::UserRole,
                 Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const;
int findText(const QString &amp;text,
                        Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const;
void insertItem(int index, const QString &amp;text, const QVariant &amp;userData = QVariant());
void insertItem(int index,const QIcon &amp; icon, const QString &amp;text, const QVariant &amp;userData = QVariant());
void insertItems(int index, const QList &lt;QString&gt; &amp;list);
QVariant itemData(int index, int role = Qt::UserRole ) const;
QIcon itemIcon (int index) const;
QString itemText(int index) const;
void removeItem(int index);
void setCurrentIndex(int index);
void setItemData( int index, const QVariant &amp; value, int role = Qt::UserRole );
void setItemIcon(int index, const QIcon &amp;icon);
void setItemText(int index, const QString &amp;text);





static QList &lt;Item&gt;&amp; getItems(){return items;}
void setColumnWidth ( int column, int width );
void setRowHeight ( int row, int height );
QList &lt;QString&gt; toString();








Item&amp; getItem(int index);
</code></pre>
<p dir="auto">signals:</p>
<pre><code>void itemsEdited();
//void activated ( int index );
</code></pre>
<p dir="auto">public slots:</p>
<pre><code>void clear();
void shout(int index);
void shout(const QString&amp; text);
</code></pre>
<p dir="auto">protected:</p>
<pre><code>void wheelEvent(QWheelEvent *e);
void _q_emitCurrentIndexChanged(const QModelIndex &amp;index);
void _q_emitHighlighted(const QModelIndex &amp;index);
</code></pre>
<p dir="auto">protected slots:</p>
<pre><code>void giveOut();
void updateTable();
void emitActivated();
</code></pre>
<p dir="auto">private:</p>
<pre><code>static QList &lt;Item&gt; items;
QTableView *view;
int columns;
bool returnZero;
QModelIndex currentIndex_;
TableModel *model;
QLineEdit *line;
void insertSeparator(int index){}
bool actLock;
</code></pre>
<p dir="auto">};</p>
<p dir="auto">//-------------------------Table Model ----------------------------------------</p>
<p dir="auto">class TableModel : public QAbstractTableModel</p>
<p dir="auto">{<br />
Q_OBJECT</p>
<p dir="auto">public:</p>
<p dir="auto">TableModel(int rows, int cols, QObject* parent = 0): QAbstractTableModel(parent), rows(rows), cols(cols){}</p>
<p dir="auto">int rowCount(const QModelIndex&amp; parent = QModelIndex()) const { return rows;}<br />
int columnCount(const QModelIndex&amp; parent = QModelIndex()) const { return cols; }<br />
void setRows(int i){rows=i;}<br />
void setCols(int i) {cols=i;}</p>
<p dir="auto">QVariant data(const QModelIndex&amp; index, int role = Qt::DisplayRole) const;</p>
<p dir="auto">private:</p>
<p dir="auto">int rows;<br />
int cols;</p>
<p dir="auto">};</p>
<p dir="auto">#endif // COMBOTABLE_H</p>
<p dir="auto">@</p>
]]></description><link>https://forum.qt.io/post/58553</link><guid isPermaLink="true">https://forum.qt.io/post/58553</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 25 Oct 2010 09:09:47 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Sat, 16 Oct 2010 08:36:47 GMT]]></title><description><![CDATA[<p dir="auto">hi, can you post more complete test program, many parts missing in your code above. Then someone can try further for solution</p>
]]></description><link>https://forum.qt.io/post/57738</link><guid isPermaLink="true">https://forum.qt.io/post/57738</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 16 Oct 2010 08:36:47 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Fri, 15 Oct 2010 13:50:27 GMT]]></title><description><![CDATA[<p dir="auto">Does not work as well! :(</p>
]]></description><link>https://forum.qt.io/post/57673</link><guid isPermaLink="true">https://forum.qt.io/post/57673</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 15 Oct 2010 13:50:27 GMT</pubDate></item><item><title><![CDATA[Reply to Catch a signal from a parent class and send your own same named signal? on Fri, 15 Oct 2010 11:59:46 GMT]]></title><description><![CDATA[<p dir="auto">don't use dynamic_cast. Try qobject_cast.</p>
]]></description><link>https://forum.qt.io/post/57660</link><guid isPermaLink="true">https://forum.qt.io/post/57660</guid><dc:creator><![CDATA[alexander]]></dc:creator><pubDate>Fri, 15 Oct 2010 11:59:46 GMT</pubDate></item></channel></rss>