1

I use a QDial control for input time values in sec. How do I change the automatically added text that shows up in the middle of these dials?

enter image description here

EDIT: They come from the QtCurve style.

demonplus
  • 5,613
  • 12
  • 49
  • 68
user877329
  • 6,717
  • 8
  • 46
  • 88
  • I am a bit confused, what does the QDial ( setMin() and setMax() values your seconds can go ) have to do with the label displaying your value as a hour/min/sec format ( hint `QString(%1 : %2 : %3 ).arg...` plus simple math ) ? – Najzero Jul 25 '13 at 12:35
  • user877329 I assume it was you who down voted my answer and if I'm correct, then you should at least show some respect on SO to people who are trying to help you, especially with such a poorly written question that you have presented. As the comment by @Najzero also shows, we don't understand what you're trying to ask. user877329, if it wasn't you, then I apologise for this outburst and it's infuriating when cowards downvote without an explanation. – TheDarkKnight Jul 25 '13 at 12:47

2 Answers2

1

If there is no code in your program to explicitly display this integral value (in a signal/slot), then it may very well be your current Qt Style which does it. See the following examples of Qt styles to see that the display of this integer is usually NOT part of the QDial display:

http://qt-project.org/doc/qt-4.8/gallery-plastique.html

http://qt-project.org/doc/qt-4.8/gallery-cde.html

http://qt-project.org/doc/qt-4.8/gallery-gtk.html

http://qt-project.org/doc/qt-4.8/gallery-cleanlooks.html

http://qt-project.org/doc/qt-4.8/gallery-windowsvista.html

http://qt-project.org/doc/qt-4.8/gallery-macintosh.html

See: http://qt-project.org/doc/qt-4.8/qstyle.html for more info on styles.

You can also look in your program code for the following code:

 QApplication::setStyle(...);

You could also check the following:

  • QT_STYLE_OVERRIDE environment variable
  • -style= argument passed to your program

If you still don't find how your style is set, then it may be the default style for your platform.

What does the following says ?

QStyle *currentStyle = QApplication::style();
qDebug() << currentStyle;
qDebug() << currentStyle->objectName();
qDebug() << currentStyle->metaObject()->className();

EDIT: I see you identified the style to be QtCurve.

Source is there: http://kde-look.org/content/download.php?content=40492&id=1&tan=23640920

And we can see that the style is responsible for displaying the value:

file: style/qtcurve.cpp, line: 7980

                // Draw value...
#ifdef DIAL_DOT_ON_RING
                drawItemTextWithRole(painter, outer.adjusted(sliderWidth, sliderWidth, -sliderWidth, -sliderWidth),
                                     Qt::AlignCenter, palette, state&State_Enabled,
                                     QString::number(slider->sliderValue), QPalette::ButtonText);
#else
                int adjust=2*sliderWidth;
                drawItemTextWithRole(painter, outer.adjusted(adjust, adjust, -adjust, -adjust),
                                     Qt::AlignCenter, palette, state&State_Enabled,
                                     QString::number(slider->sliderValue), QPalette::ButtonText);
#endif

From now on, you can either:

  • Recompile the style after disabling the faulty code (commenting or using a boolean option).
  • Ask the maintainer to provide an option to disable the display of the dial's value.
fjardon
  • 7,921
  • 22
  • 31
  • Well, explicity changing style at application startup removes these labels. However grep -r "setStyle" . in my project folder gives no hits. – user877329 Aug 02 '13 at 18:32
  • Apparently, QtCurve is widely used under linux because it exists under Gtk and Kde. It thus provides a uniform look and feel to desktop applications, whatever toolkit they use. – fjardon Aug 04 '13 at 11:51
  • Good addendum. If I recompile the style, can I have that modified version only affecting this app (without modifying environment variables or adding extra command line options) or do I need to overwrite the one packaged with the system? – user877329 Aug 04 '13 at 14:51
0

Assuming you mean sec as in seconds? You can work out the percentage of where the dial is relative to its full rotation and then apply that to the percentage of maximum seconds.

For example, if the dial goes from 0 to 360 and the current position is at 90, its percentage is

90 / 360 * 100 = 25%.

If your maximum value in seconds is 60, then 25 percent of 60.

25 / 100 * 60 = 15 seconds.

So the display would now show 15 seconds.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • Shure, thats elementary. Whats the API to change what the control sais. Now it sais the integer value, but internally I use a float between 0 and 1. This is an JACK app so 1 second range is natural. – user877329 Jul 25 '13 at 12:40
  • Sorry, I don't understand you. What do you mean 'it says the integer value'? Are you trying to tell me that the values are from 0 to 1, instead of 0 to 360? Also, I have no idea what a JACK app is. – TheDarkKnight Jul 25 '13 at 12:43
  • The control sais an integer value representing an internal state. The user wants the physical interpretation so he do not need to know that the range behind is [0, 1]. – user877329 Jul 25 '13 at 12:58
  • 2
    Where are the numbers in the dial coming from? QDial does not have this. Are you displaying these in a QLabel and setting its value based on the dial? – TheDarkKnight Jul 25 '13 at 13:02
  • It really seems like they actually are a part of the QDial – user877329 Aug 02 '13 at 14:05