QScale
Qt Widgets
Score 59%
Description:

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.

Totoxa

3 years ago

I have ported your widget to Python.

http://pastebin.com/kzp7f7DS

Report

C

mmj

3 years ago

Hi Totoxa,

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

1 year ago

http://pastebin.com/qR6KNTwr

Only took a teeny bit of tweaking to upgrade to PyQt5.

Report

altendky

1 year ago

Formally published on GitHub:
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

MarkoSiroki

3 years ago

What about mirrored view of component?

Report

paulpeter

4 years ago

Hi guys.

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

5 years ago

oh what i forgot:

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

C

mmj

5 years ago

Hi,
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

5 years ago

Hi,

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

5 years ago

Thanks mmj. This is exactly i was looking for. Thanks to you , my work has been reduced a lot.
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

C

mmj

5 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.

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

5 years ago

Thank you for your code, It's wonderful!

Report

Deusdies

5 years ago

PLEASE write a QtDesigner plugin! I don't know how to use it otherwise :( Any tips?

Thanks

Report

C

mmj

5 years ago

Hi, to integrate it in your project you can copy qscale.h and qscale.cpp into your project. Then include this two files in your project file as you see it in QScale.pro. Now you can include qscale.h in your program and create a instance. This you can see in the main.cpp file.

Report

chriskon149

5 years ago

Copy the header and source files into your project directory. From there, add them to your .pro file. Go to QtCreator, drag and drop a "Widget" widget onto your UI and scale it to the size of the custom widget you want to use. Right click it and click "Promote To". Then type in the name of the header file, click "Add" and then select it from the list. Then click "promote."

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

chriskon149

5 years ago

Edit: Apparently this is from 2012 and NOT 2010... My bad. I just misread the date. XD

Report

C

mmj

5 years ago

Oh, I did not knew this yet. Nice hint. (especially as I have currently can't effort the time to write the plugin)

Report

File (click to download) Version Description Filetype Packagetype License Downloads Date Filesize OCS-Install DL
Details
version
0.1
updated Jan 07 2012
added Jan 07 2012
downloads today
0
page views today 4