
QScale
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
This is a analog scale widget. It might be interesting especially in case you want to write nice GUIs for laboratory devices (as I did) or you want a freaky monitoring widget.
It is fully resizable and supports a horizontal as well as vertical scale.
The scale is completely derived from the scale range and the geometry (it is also possible to control the steps manually).
I've made some screenshots where I've just changed min, max and current value (resizing was done after running).
In the last screenshots I showed the hiding of scale and values and changed my desktop color scheme.
If you use the widget, I'd be glad if you leave a comment. This might encourage me to create a Designer plugin or do other further work at other parts of the code.
hakan
1 year ago
Report
rk42
1 year ago
Report
rk42
1 year ago
Report
Totoxa
6 years ago
http://pastebin.com/kzp7f7DS
Report
mmj
6 years ago
it's awesome to see, that people are using this code. Tanks for the Python port.
I think it will be my preferred way to use it, in case I have to implement a new GUI for lab devices.
Report
altendky
5 years ago
https://github.com/altendky/st/blob/3d70302313375001b2dcc27f086be2a98bea74ed/epyq/qscale.py
If either of you have any concerns about copyright or licensing, please let me know so I can address them. Oh yeah, and thanks for sharing!
Report
altendky
5 years ago
Only took a teeny bit of tweaking to upgrade to PyQt5.
Report
MarkoSiroki
6 years ago
Report
paulpeter
7 years ago
This patch adds Qt 5 support for the widget above. Furthermore all methods used to configure the scale are now exposed to qt's property system.
https://gist.github.com/anonymous/6211838
Report
Elektrofreak
8 years ago
3) Colours indicating good and not good ranges, e.g. if the current increases to the maximum value. The colours could be placed as a background behind the scale numbers or not as a background but the fonts/colours of the lines and numbers.
Hope you like the ideas, looking forward to hear from you :-D
Report
mmj
8 years ago
thanks for your comments.
1) I've quickly looked into the code to see, why it does not work with switches max/min values. Here is a quick patch:
289c289
< for(int i = 0; i <= (int)(minorSteps * valueSpan / majorStep); i++){
---
> for(int i = 0; i <= (int)(minorSteps * abs(valueSpan) / majorStep); i++){
295c295
< painter->rotate(majorStep * angleSpan / (-valueSpan * minorSteps));
---
> painter->rotate(majorStep * angleSpan / (-fabs(valueSpan) * minorSteps));
302,303c302,303
< for(int i = (int)ceil(m_minimum / majorStep);
< i <= (int)(m_maximum / majorStep); i++){
---
> for(int i = (int)ceil(fmin(m_minimum, m_maximum) / majorStep);
> i <= (int)(fmax(m_minimum, m_maximum) / majorStep); i++){
I've done this in quite short time, and I don't know the code anymore, as I have written it years ago. So it is not unlikely, that it has inintended side effects.
2) I initially planned to do that, but I think you are more flexible, when using a extra widget. In my applications I did it that way. The reason is, that it looks too tiny, if you use the standard font. In case you make it bold and bigger, it does not line up with the other fonts in the GUI. So the only option is to provide full font formatting options in the API. This produces code and you still are less flexible (can not use QLCDNumber).
3) This should be easy to add (filling some circle with a QConicalGradient brush). The only effort is to write a sensible API to define the velues for that.
Well, while these things are no big deal, I'm not shure, If I find time in near future to add them, as I did not program in C++ for years now.
Report
Elektrofreak
8 years ago
first i want to thank you for this nice widget! What i would like to have would be two features:
1) Vertical orientation: Could be the top value 100% and the bottom value 0%? (switched with a function)
2) Value presentation: Could the value shown also be written under the window? The idea is that you have a quick and neat view of the value and an exact value to be read as a text. You could also do this within the app where you use QScale but i think it would not look as nice as it is within QScale ;-)
Report
rugi
8 years ago
By the way , can you please elaborate , how you have decided the formula for radius and other parameters? This will help me to add some more feature for my work.
Report
mmj
8 years ago
I've uploades some scratches at http://www.2shared.com/file/lZOLuK_e/QScale-construction.html
This are some geometrical scratches, as I don't have the derivation of the formulars at hand.
This explains the derivation of the rotation point. The label bounding box is the bounding box from the labelSample as derived in updateLabelSample()
Report
kyokyojiang
8 years ago
Report
Deusdies
8 years ago
Thanks
Report
chriskon149
8 years ago
For a video tutorial, see here: http://youtu.be/VyVKbZAriK4
(I know how old these comments are, so I'm leaving this here for other people who may come across this issue.)
Report
mmj
8 years ago
Report
chriskon149
8 years ago
Report
mmj
8 years ago
Report