[Qt-interest] dataChanged() SIGNAL in proxy models
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Thu Jul 1 10:59:24 CEST 2010
On Thu, Jul 1, 2010 at 2:16 PM, Tony Rietwyk
<tony.rietwyk at rightsoft.com.au> wrote:
> Hi Mandeep,
>
> I haven't used proxy models, but I'm surprised that the dataChanged signal
> isn't mapped for you. Connecting the source signal to the proxy's signal
> won't work, since the source index parameter refers to the source model,
> which the table view won't recognise. When you connected to a slot, did you
> map the source index to the proxy's rows & columns?
Oops! I forgot...I should've called mapFromSource() in the slot....
<snip>
void setSourceModel(QAbstractItemModel *sourceModel)
{
QAbstractProxyModel::setSourceModel(sourceModel);
connect(sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(dataChangeSlot(QModelIndex,QModelIndex)));
}
public slots:
void dataChangeSlot(const QModelIndex &topLeft, const QModelIndex
&bottomRight)
{
emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight));
}
signals:
void dataChanged(const QModelIndex &, const QModelIndex &);
</snip>
This works. Though I was hoping that this should be handled by the
abstract proxy model since there nothing subclass implementation
specific being done here (I haven't checked the source of
QAbstractProxyModel yet).
>
> Hope that helps,
It did. Thanks! :)
Regards,
-mandeep
>
> Tony
More information about the Qt-interest-old
mailing list