[Qt-interest] Blocking signals from / to MVC components.

MARTIN Pierre hickscorp at gmail.com
Wed Sep 21 14:58:18 CEST 2011


Ok guys, i think i have found a "not-too-dirty" solution, tell me if you something which can go wrong with this idea. Lets say my implementation of my QSqlTableModel derived class looks like this:

bool	setData		(QModelIndex const &i, QVariant const &v, int r=Qt::EditRole) {
	// First make sure that the column for which data is being set is the blob, and the signals are not blocked already.
	bool		block	= i.column()==MyModel::BinaryBlobNotShownInTablesAndViews && !signalsBlocked()
	// Block if needed.
	if (block)				blockSignals	(true);
	// Set the data, get the success flag.
	bool		ok		= QSqlTableModel::setData(i, v, r);
	// Unblock signals if blocked by this method.
	if (block)				blockSignals	(false);
	return		ok;
}

What do you think? i made a draft of it, and i don't loose selection anymore :)

Thank you guys,
Pierre.




More information about the Qt-interest-old mailing list