Qt-interest Archive, October 2006
[Qt4] blockSignals not working with QTableWidget?
Message 1 in thread
Hi,
When adding a QTableWidgetItem in a QTableWidget using setItem(int row, int
column, QTableWidgetItem* item) between a blockSignals(true) /
blockSignals(false) section, the cellChanged(int row, int column)
is nevertheless emitted. Is this an expected behaviour? In this case, how to
prevent the cellChanged(int row, int column) signal from being emitted?
Many thanks,
Emeric
PS: The cellChanged(int row, int column) was added with Qt 4.1. I'm
experiencing this issue with Qt 4.1.4 on an Itanium system (IA-64
architecture) running up-to-date Debian Etch.
Message 2 in thread
>
> In Qt4 the QTableWidget is a convenience class for QTableView with a
> default model.
>
> I guess (didn't confirm it) you have to block the signals by the model
> too.
>
Thanks Daniel for this information. But... how do you actually block the
signals "by the model"? Is there some documentation about this concept?
Emeric
Message 3 in thread
See Documentation of QAbstractItemModel
http://doc.trolltech.com/4.2/qabstractitemmodel.html <http://doc.trolltech.com/4.2/qabstractitemmodel.html>
To get the model simply use
QTableWidget *pTable = new QTableWidget();
QAbstractItemModel *pModel = pTable->model();
(QTableWidget inherits from QTableView which inherits from QAbstractItemView)
Hope that helps you in any way.
Daniel
________________________________
Von: Émeric Maschino [mailto:emeric.maschino@xxxxxxxxx]
Gesendet: Montag, 23. Oktober 2006 12:51
An: qt-interest@xxxxxxxxxxxxx
Betreff: Re: [Qt4] blockSignals not working with QTableWidget?
In Qt4 the QTableWidget is a convenience class for QTableView with a default model.
I guess (didn't confirm it) you have to block the signals by the model too.
Thanks Daniel for this information. But... how do you actually block the signals "by the model"? Is there some documentation about this concept?
Emeric
Message 4 in thread
>
> To get the model simply use
>
> QTableWidget *pTable = new QTableWidget();
>
> QAbstractItemModel *pModel = pTable->model();
>
> (QTableWidget inherits from QTableView which inherits from
> QAbstractItemView)
>
> Hope that helps you in any way.
>
And then you think I simply need to do a pModel->blockSignals(true) to
disable the emitted signals? I can't test this right now, hence my question.
Thanks anyway Daniel, it's a possible solution and I'll report success or
failure on this list.
Emeric
Message 5 in thread
2006/10/23, Émeric Maschino <emeric.maschino@xxxxxxxxx>:
>
> To get the model simply use
> >
> > QTableWidget *pTable = new QTableWidget();
> >
> > QAbstractItemModel *pModel = pTable->model();
> >
> > (QTableWidget inherits from QTableView which inherits from
> > QAbstractItemView)
> >
> > Hope that helps you in any way.
> >
>
> And then you think I simply need to do a pModel->blockSignals(true) to
> disable the emitted signals? I can't test this right now, hence my question.
>
> Thanks anyway Daniel, it's a possible solution and I'll report success or
> failure on this list.
>
> Emeric
>
The solution proposed by Daniel works like a charm: model->blockSignal()
(where model is a QAbstractItemModel*) did the trick for me.
Many thanks,
Emeric