Default values in form

60 views
Skip to first unread message

Lionel Roubeyrie

unread,
Mar 27, 2013, 8:44:10 AM3/27/13
to project...@googlegroups.com
Hi all,
With each blank float (or integer) field displayed in a form, defined as nullable=True in the model, if the user selects the field (with mouse or with the tab key) and leaves it without entering a value, the float (or integer) field is automatically set to 0.0 (or 0). How can we specify to camelot to let this field empty?
Thanks

Erik Janssens

unread,
Mar 27, 2013, 12:56:38 PM3/27/13
to project...@googlegroups.com

Hello Lionel,

 

yes, this is indeed a problem.

 

however the issue is with the editor itself in Qt. Qt makes no

distinction between 0 and NULL as is done in the database

world.

 

when the release is out of the door, the plan is to go through

the editors again and investigate these sort of issues as well

as adding configureable action buttons to the editors.

 

should you come up with a solution to this issue, it's welcome !

 

Cheers,

 

Erik

--
--
You received this message because you are subscribed to the "Project Camelot" group.
Visit www.python-camelot.com for more information
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-camel...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-camelot?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Project Camelot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-camel...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



Adrian Klaver

unread,
Mar 27, 2013, 7:38:52 PM3/27/13
to project...@googlegroups.com, Erik Janssens
On 03/27/2013 09:56 AM, Erik Janssens wrote:
> Hello Lionel,
>
> yes, this is indeed a problem.
>
> however the issue is with the editor itself in Qt. Qt makes no
>
> distinction between 0 and NULL as is done in the database
>
> world.
>
> when the release is out of the door, the plan is to go through
>
> the editors again and investigate these sort of issues as well
>
> as adding configureable action buttons to the editors.
>
> should you come up with a solution to this issue, it's welcome !

Seems this is a two part problem.

1) Qt believes NULL = 0 which is wrong.
2) The wrong value propagates to the database.

I am still working my way through Camelot, so I do not have an answer,
but questions.

Is it possible to catch the empty value in 1 and override Qt to send out
a NULL value?

Failing that, is it possible to flag that an empty value was intended in
1 and prevent that field from being included in the INSERT/UPDATE?

>
> Cheers,
>
> Erik
>



--
Adrian Klaver
adrian...@gmail.com

Erik Janssens

unread,
Mar 29, 2013, 1:35:34 PM3/29/13
to project...@googlegroups.com
I think the solution should be in 1, because after the
editor its value is set, it cannot be told if it came from the
user, or the editor created it itself.

the only way to make 2 work is when for example 0 is
a not allowed value in the field, then you could catch
0 in the model and set it to None


--
--
You received this message because you are subscribed to the "Project Camelot" group.
Visit www.python-camelot.com for more information

To post to this group, send email to project-camelot@googlegroups.com

To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/project-camelot?hl=en

--- You received this message because you are subscribed to the Google Groups "Project Camelot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-camelot+unsubscribe@googlegroups.com.

Lionel Roubeyrie

unread,
May 18, 2013, 4:59:32 AM5/18/13
to project...@googlegroups.com
Hi all,
one solution is to use a minimum value (say -1) for a float field which needs to go from 0 to... whaterver you want, and use a custom FloatEditor where you set self.spinBox.setSpecialValueText('--') and redefine its set_value and get_value methods, plus the CustomDoubleSpinBox which haves to return a blank QString if needed.
Cheers
floateditor.diff

Erik Janssens

unread,
May 22, 2013, 2:40:55 AM5/22/13
to project...@googlegroups.com
Hello Lionel,

that's indeed the solution described in the docs, the only issue with this one is tat if there
is -1 in the database, you will display the special text (this -1 might have been inserted
by another application), or in the worst case, send this -1 again to the database as None.

but this might be the less evil thing to do ??

Erik

--
--
You received this message because you are subscribed to the "Project Camelot" group.
Visit www.python-camelot.com for more information
 
To post to this group, send email to project...@googlegroups.com

To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/project-camelot?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Project Camelot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-camel...@googlegroups.com.

Lionel Roubeyrie

unread,
May 22, 2013, 3:00:59 AM5/22/13
to project...@googlegroups.com, erik.j...@conceptive.be
Hi Erik,
yes, it's not perfect, but for the moment there's no hundred of others solutions. Setting a step of 1, the float field can go from 0 to maxfloat, and can have a None value. This is, like you say, if there's no another application which comes to modify values directly in the database, but in most cases the Camelot app is the only one.
Another solution would be reimplement a float editor from scratch... :-p
Reply all
Reply to author
Forward
0 new messages