missing keyboardTracking property for Gui::PrefQuantitySpinBox

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by uwestoehr »

I wanted to apply the keyboardTracking property to the PD Pad dialog fields because having e.g. 4 recomputes just to type in "13,8" cost a lot of time for complex geometries.

This way I realized that the Gui::PrefQuantitySpinBox does not yet have this property while Werner added this recently to Gui::QuantitySpinBox.

Werner, is there a reason? Could you add this to the *Pref* class too or should I do something else with the Pad dialog? (just using the Gui::QuantitySpinBox does not work because then we loose the history saving feature)
wmayer wrote: .
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by wmayer »

Based on https://forum.freecadweb.org/viewtopic. ... 54#p406537 I have tested this Python snippet:

Code: Select all

from PySide2 import QtCore

ui=Gui.UiLoader()
sp=ui.createWidget("Gui::PrefQuantitySpinBox")
sp.setKeyboardTracking(False)
sp.setProperty("unit","mm")

sp.valueChanged.connect(lambda: print(sp.text()))
sp.show()
When typing the numbers with the keyboard no text is printed. Only when using the mouse wheel or the spin buttons some text is printed. It would also be illogical because PrefQuantitySpinBox inherits from QuantitySpinBox and doesn't override any of the virtual methods of its base class.

If things don't work as expected then something else must be wrong.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by openBrain »

wmayer wrote: Sat Aug 08, 2020 9:26 am When typing the numbers with the keyboard no text is printed. Only when using the mouse wheel or the spin buttons some text is printed. It would also be illogical because PrefQuantitySpinBox inherits from QuantitySpinBox and doesn't override any of the virtual methods of its base class.

If things don't work as expected then something else must be wrong.
It works as expected @wmayer. ;) When KeyboardTracking is set to 'True', signal is emitted for each character. ;)
To me this is what it should be.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by openBrain »

uwestoehr wrote: Sat Aug 08, 2020 2:20 am I wanted to apply the keyboardTracking property to the PD Pad dialog fields because having e.g. 4 recomputes just to type in "13,8" cost a lot of time for complex geometries.

This way I realized that the Gui::PrefQuantitySpinBox does not yet have this property while Werner added this recently to Gui::QuantitySpinBox.
Can you share a snippet that demonstrates the problem ?
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by uwestoehr »

wmayer wrote: Sat Aug 08, 2020 9:26 am If things don't work as expected then something else must be wrong.
I purposely use Qt's designer because it prevents me from making mistakes. And there I see for Gui::QuantitySpinBox the QAbstractSpinBox properties:

Gui::QuantitySpinBox
Gui::QuantitySpinBox
explorer_OOAkxvWgT3.png (117.87 KiB) Viewed 1021 times

For Gui::PrefQuantitySpinBox I don't get them:

Gui::PrefQuantitySpinBox
Gui::PrefQuantitySpinBox
designer_X0smrcTKcU.png (101.04 KiB) Viewed 1021 times

It seems that my recent rebuilt of the designer plugins is fishy. I will rebuild it now and report back.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by wmayer »

I purposely use Qt's designer because it prevents me from making mistakes. And there I see for Gui::QuantitySpinBox the QAbstractSpinBox properties:
The FreeCAD widgets plugin is only to provide something visible and offer the Qt properties inside the designer. But functionality-wise it's very limited because it otherwise would require to be linked against the FreeCAD core libraries (i.e. FreeCADBase, App, Gui) that would make things much more complicated. So, you really have to compile your changes and test within the running FreeCAD instance.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by uwestoehr »

uwestoehr wrote: Sat Aug 08, 2020 11:57 am It seems that my recent rebuilt of the designer plugins is fishy. I will rebuild it now and report back.
I rebuilt it now from scratch and see that the designer plugin does not have a class PrefQuantitySpinBox.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by uwestoehr »

This PR add the missing class to the designer plugin:
https://github.com/FreeCAD/FreeCAD/pull/3789

With this PR designer looks like this:
devenv_yqgZaixFKm.png
devenv_yqgZaixFKm.png (108.48 KiB) Viewed 1003 times

I simply inherited the UI features of Gui::QuantitySpinBox for Gui::PrefQuantitySpinBox. But I am a total newbie in this area. Werner, can you therefore please have a look at my PR?
chrisb
Veteran
Posts: 54288
Joined: Tue Mar 17, 2015 9:14 am

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by chrisb »

openBrain wrote: Sat Aug 08, 2020 9:56 am To me this is what it should be.
This would be ok, if it wasn't for this very common use case, e.g. when changing the length from 10 to 20:
change the length by removing the first character and write a "1" instead.

As I still think that errors matter I have the auto-raise for report view enabled, and having removed the first character throws an error because the pad has length zero.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: missing keyboardTracking property for Gui::PrefQuantitySpinBox

Post by openBrain »

chrisb wrote: Sat Aug 08, 2020 2:31 pm This would be ok, if it wasn't for this very common use case, e.g. when changing the length from 10 to 20:
change the length by removing the first character and write a "1" instead.

As I still think that errors matter I have the auto-raise for report view enabled, and having removed the first character throws an error because the pad has length zero.
Wrong topic? There's no pad here. Just something that works the way it has to. ;)
Post Reply