Search code examples
c++qtqt-designerqdial

QDial change position indicator text


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.


Solution

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