Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
uwestoehr
Posts: 1446
Joined: Sun Jan 27, 2019 3:21 am

Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by uwestoehr » Thu Mar 26, 2020 11:13 pm

I noticed an issue in FC's definition of Gui::PrefUnitSpinBox and Gui::QuantitySpinBox.
They don't inherit e.g. the alignment property from QAbstractSpinBox. Other spin boxes have this and therefore support these useful settings:
qtcreator_GHqTPR0N77.png
QAbstractSpinBox properties
qtcreator_GHqTPR0N77.png (7.84 KiB) Viewed 289 times

Is it OK to add this inheritance? I would e.g. like to set the alignment for all spin boxes in a dialog, not only for the Q spin boxes.
User avatar
uwestoehr
Posts: 1446
Joined: Sun Jan 27, 2019 3:21 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by uwestoehr » Thu Mar 26, 2020 11:28 pm

uwestoehr wrote:
Thu Mar 26, 2020 11:13 pm
They don't inherit e.g. the alignment property from QAbstractSpinBox.
Hmm, looking in the code, they seem to do but Qt designer doesn't not recognize them. I can also not find anything about this in
https://wiki.freecadweb.org/Developer_hub
I also searched the Wiki.

So how can I tell Qt designer how to handle the GUI:: widgets?
User avatar
wandererfan
Posts: 3876
Joined: Tue Nov 06, 2012 5:42 pm

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by wandererfan » Thu Mar 26, 2020 11:39 pm

uwestoehr wrote:
Thu Mar 26, 2020 11:13 pm
I noticed an issue in FC's definition of Gui::PrefUnitSpinBox and Gui::QuantitySpinBox.
They don't inherit e.g. the alignment property from QAbstractSpinBox. Other spin boxes have this and therefore support these useful settings:
They already inherit QAbstractSpinBox. Maybe your plugin (libFreeCAD_widgers.so on linux. don't know about Win) is not up to date?

see QuantitySpinBox.h

Code: Select all

class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBinding
and in Qt5 Designer:
GQSBInherit.png
GQSBInherit.png (70.71 KiB) Viewed 282 times
wmayer
Site Admin
Posts: 15749
Joined: Thu Feb 19, 2009 10:32 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by wmayer » Fri Mar 27, 2020 7:33 am

uwestoehr wrote:
Thu Mar 26, 2020 11:28 pm
uwestoehr wrote:
Thu Mar 26, 2020 11:13 pm
They don't inherit e.g. the alignment property from QAbstractSpinBox.
Hmm, looking in the code, they seem to do but Qt designer doesn't not recognize them. I can also not find anything about this in
https://wiki.freecadweb.org/Developer_hub
I also searched the Wiki.

So how can I tell Qt designer how to handle the GUI:: widgets?
It's not a matter of inheritance but a matter of the lack of the Qt plugin. It's possible to use custom FreeCAD widgets in the designer without the FreeCAD plugin but its usage is limited. If you look at the XML code inside a .ui file and search for QuantitySpinBox you can see that adding custom properties is possible and at the end you will see there is a block:

Code: Select all

  <customwidget>
   <class>Gui::QuantitySpinBox</class>
   <extends>QWidget</extends>
   <header>Gui/QuantitySpinBox.h</header>
  </customwidget>


The problem here is that in real C++ QuantitySpinBox inherits from QAbstractSpinBox but it's not possible to say so in the .ui file because QAbstractSpinBox is an abstract class and cannot be instantiated. If you try it anyway the designer raises an error when loading the modified .ui file.

To have full access over QuantitySpinBox in Qt designer then the only option is to build the FreeCAD plugin and put it into the plugins directory of your Qt installation.
User avatar
uwestoehr
Posts: 1446
Joined: Sun Jan 27, 2019 3:21 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by uwestoehr » Fri Mar 27, 2020 12:14 pm

wmayer wrote:
Fri Mar 27, 2020 7:33 am
To have full access over QuantitySpinBox in Qt designer then the only option is to build the FreeCAD plugin and put it into the plugins directory of your Qt installation.
I want to do so and document this in my build on Windows instructions in the Wiki. However, it is not yet clear to me how this is done.
In my build folder I find the folder "QtUiPlugin" that contains custom Qt designer widgets. But how do I say Qt designer to use them?
wmayer
Site Admin
Posts: 15749
Joined: Thu Feb 19, 2009 10:32 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by wmayer » Fri Mar 27, 2020 1:44 pm

You must build this plugin: https://github.com/FreeCAD/FreeCAD/tree ... ins/widget

On Windows open command line shell from within VS or of the VS installation in the start menu. Then cd to the directory and enter

Code: Select all

qmake plugin.pro
nmake -f Makefile.Release
Copy the dll to the designer sub-directory of the plugins folder of Qt.
User avatar
uwestoehr
Posts: 1446
Joined: Sun Jan 27, 2019 3:21 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by uwestoehr » Fri Mar 27, 2020 3:21 pm

wmayer wrote:
Fri Mar 27, 2020 1:44 pm
You must build this plugin: https://github.com/FreeCAD/FreeCAD/tree ... ins/widget

On Windows open command line shell from within VS or of the VS installation in the start menu. Then cd to the directory and enter

Code: Select all

qmake plugin.pro
nmake -f Makefile.Release
Copy the dll to the designer sub-directory of the plugins folder of Qt.
Thanks. However, I am not able to build this, because despite I am in the VS shell for x64, it tells me that the target destination is x86:
cmd_ay0SL85Rse.png
cmd_ay0SL85Rse.png (48.08 KiB) Viewed 192 times

I cannot find a way to tell qmake and nmake to use the x64 version.
User avatar
wandererfan
Posts: 3876
Joined: Tue Nov 06, 2012 5:42 pm

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by wandererfan » Fri Mar 27, 2020 4:21 pm

uwestoehr wrote:
Fri Mar 27, 2020 3:21 pm
I cannot find a way to tell qmake and nmake to use the x64 version.
do you have both Qt4 and Qt5 installed? If so, you may need to point at the Qt5 version of qmake.

I've run into this on Linux, don't know if it applies to Win.
User avatar
uwestoehr
Posts: 1446
Joined: Sun Jan 27, 2019 3:21 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by uwestoehr » Fri Mar 27, 2020 5:09 pm

wandererfan wrote:
Fri Mar 27, 2020 4:21 pm
do you have both Qt4 and Qt5 installed?
I only have Qt 5.12.1 installed here.
wmayer
Site Admin
Posts: 15749
Joined: Thu Feb 19, 2009 10:32 am

Re: Gui::QuantitySpinBox miss QAbstractSpinBox inheritance

Post by wmayer » Fri Mar 27, 2020 5:23 pm

You can also try: qmake -t vclib plugin.pro to create a VS project.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests