Handling of 'enabled' in ParameterTree #2810
MrBeee
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem Statement
Both 'enabled' and 'readonly' are defined in
class Parameter(QtCore.QObject)
.But their implementation is lacking a bit.
When a parameter is readonly, the main effect is that the 'default button' is hidden and the parameter is skipped in the tab-order.
But there is no visual confirmation that a parameter has been disabled. This hampers the end user understanding the situation.
Tried this, but it did not work
I'm aware of the possibility to apply a stylesheet on a ParameterTree item, as was suggested in this discussion topic. But that does not solve our problem, as the QLabel (
self.displayLabel
) , we are trying to influence does not have an 'enabled' or a 'readonly' state. So it does not react toreadonly
orenabled
properties in a stylesheet.Solution
The solution was to subclass
WidgetParameterItem
usingMyWidgetParameterItem
The only code that maters here is to add the following in
opsChanged()
:Example
An example is shown in the screenshot below. Note how the X, Y, Z parameters clearly stand out as 'disabled'
It would be great if this behavior can be included into the ParameterTree classes
Complete code
As
WidgetParameterItem
functions as a baseclass forNumericParameterItem
this class is affected as well.So, it needs to be updated too. The complete code is shown below. It uses Qt from within QGIS.
Beta Was this translation helpful? Give feedback.
All reactions