Issue
In qt-designer, is it possible to create a list of values(float)?So that I can choose from there any and, let's say, substituted in the formula? doubleSpinBpx values work fine:
I can enter from manually using:
razmerbloka = self.doubleSpinBox_6.value()
but I would like to choose from a list of numbers.
And in qt-designer, I found only a list of strings (Combo Box). That's not what I'd want
Solution
Values such as numbers are always rendered as a text. How you interact with this text depends on how the application's logic interprets the string and the actions it offers you to view, copy etc. it.
In your case I would go for a combo box if your values are not following a specific order (for example an increment step of a specific magnitude). A spin box requires a specific step and a range of values. Any other behaviour would only create confusion since this behaviour of this UI component in particular has been out there for a long time and users expect a specific way of interaction with it. This doesn't mean it's not possible to do it. It just requires creating a highly custom version of a spin box.
A combo box on the other hand offers a neat representation of all the values that a user can choose from. You can mix number formats, standard strings, dates etc. (not recommended since keeping things consistent is something any UI should strive for).
For Qt 5.6 users report this way of adding items. Qt 5.5 and earlier apparently don't support this feature through the designer (cannot confirm, I have Qt 5.9, where the designer works the same as described for 5.6).
If your data (in this case floating point numbers) comes from some external source (e.g. CSV file), I recommend filling the combo box's list of values in your code by using addItem()
.
Answered By - rbaleksandar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.