Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

4
Become a Fan
7.3

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.

Ratings & Comments

20 Comments

hakan

9 9 excellent

rk42

this is exactly what I need

rk42

9 9 excellent

Totoxa

I have ported your widget to Python. http://pastebin.com/kzp7f7DS

mmj

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.

altendky

http://pastebin.com/qR6KNTwr Only took a teeny bit of tweaking to upgrade to PyQt5.

altendky

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!

MarkoSiroki

What about mirrored view of component?

paulpeter

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

Elektrofreak

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

mmj

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.

Elektrofreak

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 ;-)

rugi

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.

mmj

> 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()

kyokyojiang

Thank you for your code, It's wonderful!

Deusdies

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

mmj

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.

chriskon149

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

chriskon149

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

mmj

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

Pling
0 Affiliates
Details
license
version 0.1
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 2

Other Qt Widgets:

Widget Virtual Keyboard
embitel
last update date: 15 years ago

Score 5.3

Widget Marquee Label
embitel
last update date: 15 years ago

Score 6.1

Widget Color Picker
embitel
last update date: 15 years ago

Score 4.7

QtitanDataGrid advanced Grid for Qt
BigZ1
last update date: 7 years ago

Score 5.7

QtitanRibbon Microsoft RibbonUI and Office Styles for Qt
BigZ1
last update date: 7 years ago

Score 5.2

Q7TaskBar
QDevelopper
last update date: 13 years ago

Score 6.1