[Interest] submit policy

Stefan nohoo77 at yahoo.com
Fri Jun 22 07:47:07 CEST 2012


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/20120621/d8248f7b/attachment.html>


More information about the Interest mailing list