[Interest] QDataWidgetMapper issues
Danny Price
deepblue842 at googlemail.com
Tue Jan 8 10:19:22 CET 2013
I'm having trouble using the venerable QDataWidgetMapper class in my
project.
I have a set of QDoubleSpinboxes mapped to indexes in my table model. I've
set the submit policy of the mapper to manual and connected the change
signals of the widgets to the submit slot so the data in the boxes is
committed when the user scrolls the mouse wheel or the keyboard (this is
far better than having to tab out of boxes for the data to be set).
There are two issues:
1) QDoubleSpinbox emits the valueChanged signal when the data is changed
both by the user and by the mapper which leads to an endless
self-notification loop. QDoubleSpinbox doesn't have a 'valueEdited' signal
which is only emitted when the user makes a change which is big limitation.
To get around this I've subclassed it and connected a custom 'userChanged'
signal to the embedded QLineEdit's textEdited signal which has forced me to
change all my client code.
Is there away to set the data mapper to disable signals (or ignore them)
for widgets under it's control when data is being set on them? By using
blockSignals? That would avoid the need to subclass.
2) The data is quite complex and the model needs to edit some fields when
others change (e.g. they are proportionally related). It does this in the
dataChanged override and uses emit dataChanged signal when the other fields
change. This works fine the table view. The problem is that the data mapper
commits the data for ALL fields when the submit slot is called so the edits
by the model get wiped out. It's also inefficient.
Is there away to set the data mapper to only submit the data for a specific
field when it is edited instead of all of them? I've looked at the
implementation and all the important parts are hidden so subclassing is not
an option. I really shouldn't have to write my own version.
These simple design limitations (spinbox lacking a user-edited signal and
data widget mapper committing eveything) are a real pain. By contrast I
could do the whole thing in Cocoa (on the OSX) with bindings with only a
few lines of code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130108/5ed63e8f/attachment.html>
More information about the Interest
mailing list