[Interest] submit policy

Tony Rietwyk tony at rightsoft.com.au
Sat Jun 23 04:37:55 CEST 2012


Hi Stefan, 

 

When you add the widgets to the data mapper, why don't you also connect the
widgets to a common 'dataChanged' slot, in which you set a timer if not
already started, and then in the timeout, do a manual submit? 

 

Hope that helps, 

 

Tony

 

 

 

From: interest-bounces+tony=rightsoft.com.au at qt-project.org
[mailto:interest-bounces+tony=rightsoft.com.au at qt-project.org] On Behalf Of
Stefan
Sent: Friday, 22 June 2012 3:47 PM
To: interest at qt-project.org
Subject: Re: [Interest] submit policy

 

Hi all,

I am still trying to figure this out. So far without much luck.

Does anybody have a clue how this can be accomplished?

I need something like a "timedelayed submit on valuechanged"-policy, while
Qt only offers a manual and an auto submit policy for the DataWidgetMapper.

Thanks for any idea
Stefan

-------------------


Hi Mark,
thank you for your response!

I have been looking at the QItemDelegate class but am pretty unsure what
method to override.
Can you point me to the right direction?

Thank you in advance
Stefan

From: Mark Brand <mabrand at mabrand.nl>
To: Stefan <nohoo77 at yahoo.com>
Cc: Diego Schulz <dschulz at gmail.com>; "interest at qt-project.org"
<interest at qt-project.org>
Sent: Thursday, May 24, 2012 4:48 PM
Subject: Re: [Interest] submit policy

>> You're using QSqlTableModel, right? Have you tried adjusting
>> QSqlTableModel::EditStrategy to OnFieldChange?

> I am not using the QSqlTableMode, I am implementing my own
QAbstractItemModel, wrapping some driver calls to an USB device.
>
> But even if I would use QSqlTableModel, I would run into the same
problems, since "OnFieldChange" only makes sure that "All changes to the
model will be applied immediately to the database". My problem is that the
"changes to the model" come in too late already (they come in on focus
lost).

That's right, this is about the behavior of QDataWidgetMapper (sort of a
"view") not the model. The OP wants changes to be submitted to the model
even if the focus never leaves the mapped widget.

I'm pretty sure that this default behavior of QDataWidgetMapper is actually
defined by the delegate, which is QItemDelegate by default. You could use
QDataWidgetMapper::setDelegate() to use your own subclassed delegate
instead.

regards,

Mark

---------------------


Hi Diego,

I am not using the QSqlTableMode, I am implementing my own
QAbstractItemModel, wrapping some driver calls to an USB device.

But even if I would use QSqlTableModel, I would run into the same problems,
since "OnFieldChange" only makes sure that "All changes to the model will be
applied immediately to the database". My problem is that the "changes to the
model" come in too late already (they come in on focus lost). However I need
the "changes to the model" already on QWidget::valueChanged (which doesn't
exist on QWidget level), preferable time delayed for QLineEdits and
QComboBoxes.

Thank you for your input
Stefan

From: Diego Schulz <dschulz at gmail.com>
To: "interest at qt-project.org" <interest at qt-project.org>
Sent: Thursday, May 24, 2012 12:41 AM
Subject: Re: [Interest] submit policy

On Mon, May 21, 2012 at 9:15 AM, Stefan <nohoo77 at yahoo.com> wrote:
> Hello,
>
> this question is about the submit policy in QDataWidgetMapper.
>
> There is an AutoSubmit, which submits to the itemModel on focus lost.
> Also, there is a ManualSubmit, submitting only when called
programatically.
> I prefer to use the auto submit policy, since I don't want to have an ok
> button on my dialog needing to be pressed in order to make the change
> permanent. I like that the data is changed immediatly.
>
> Unfortunately the data is not being submitted until the user defocuses the
> currently changed widget, which he might or might not.
> Eventually he will, one might thinkg, but in my case the connected
ItemModel
> is a wrapper to an externally connected device sitting on the users desk,
> which he can access in parallel. In fact he is now checking this device
for
> his currently made change, but since the autosubmit policy didn't fire
yet,
> he gets a weird user experience.
> The same problem will occur with centralized databases, being accessed by
> multiple clients. One client changes a value in a widget and goes to
lunch.
> The other client still sees the old data.
>
> Does anybody know of a creative way to come up with a custom submit
policy?
> Like a SubmitOnValueChanged ? Or even a "timedelayed submit on value
> changed"-policy ?
>
> Please help
> This is bothering me for weeks now and nobody else at google seems to know
> :)
>

You're using QSqlTableModel, right? Have you tried adjusting
QSqlTableModel::EditStrategy to OnFieldChange?

>
> Thank you for any helpful input
> Stefan
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120623/b8c0bafb/attachment.html>


More information about the Interest mailing list