Important: Please read the Qt Code of Conduct -

How do you create an Object of QStyleHints

  • I am looking for a way to create an object of qstyleHints but the constructor is private. I am trying very hard to use QStylesHints

  • Moderators

    You don't create it yourself. It is created internally by the framework and you can get a pointer to that instance via static QGuiApplication::styleHints() method.

  • Is that how you gain access to its members. Cause I wanna access passworddelay function

  • Moderators

    Yup, QGuiApplication::styleHints()->passwordMaskDelay().

  • Thanks alot chris. What about the QProperty(int passwordDelay....). I need to set the delay

  • Moderators

    Sorry, what is QProperty(int passwordDelay....)? QStyleHints doesn't have anything like that.

    Or rather what are you trying to do? Maybe you're going at it the wrong way.

  • @Chris-Kawa

    QstyleHints::passwordMaskDelay() doesn't have a time in milliseconds set. it is usually read in QProperty ( int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL). I wish the guys at QT made it so that you could just pass the int into the call but that is how you set the maskdelay in milliseconds. I am trying to access it to no avail. and yes if you look at the header file for qStyleHints.h at the beginning you will see it

  • Moderators

    I'm still not sure what you mean. What class is that property in? Oh, you mean Q_PROPERTY? That's something entirely different from Qt6 QProperty.

    Anyway, this value is not meant to be writeable. It is returned by the platform style. If you want to change it you can write your own style, or a proxy. For example:

    class MyStyle : public QProxyStyle
        using QProxyStyle::QProxyStyle;
        int styleHint(QStyle::StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override
            if (hint == QStyle::SH_LineEdit_PasswordMaskDelay)
                return 42; //or whatever you want
                return QProxyStyle::styleHint(hint, option, widget, returnData);

    and set it on the application eg.

    QApplication a(argc, argv);
    a.setStyle(new MyStyle(;

  • #ifndef QSTYLEHINTS_H
    #define QSTYLEHINTS_H
    #include <QtGui/qtguiglobal.h>
    #include <QtCore/qobject.h>
    class QPlatformIntegration;
    class QStyleHintsPrivate;
    class Q_GUI_EXPORT QStyleHints : public QObject
        Q_PROPERTY(int cursorFlashTime READ cursorFlashTime NOTIFY cursorFlashTimeChanged FINAL)
        Q_PROPERTY(qreal fontSmoothingGamma READ fontSmoothingGamma STORED false CONSTANT FINAL)
        Q_PROPERTY(int keyboardAutoRepeatRate READ keyboardAutoRepeatRate STORED false CONSTANT FINAL)
        Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval NOTIFY keyboardInputIntervalChanged FINAL)
        Q_PROPERTY(int mouseDoubleClickInterval READ mouseDoubleClickInterval NOTIFY mouseDoubleClickIntervalChanged FINAL)
        Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval NOTIFY mousePressAndHoldIntervalChanged FINAL)
        Q_PROPERTY(QChar passwordMaskCharacter READ passwordMaskCharacter STORED false CONSTANT FINAL)
        /*RIGHT HERE*/Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL)
        Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL)
        Q_PROPERTY(bool showIsFullScreen READ showIsFullScreen STORED false CONSTANT FINAL)
        Q_PROPERTY(bool showIsMaximized READ showIsMaximized STORED false CONSTANT FINAL)
        Q_PROPERTY(bool showShortcutsInContextMenus READ showShortcutsInContextMenus WRITE setShowShortcutsInContextMenus NOTIFY showShortcutsInContextMenusChanged FINAL)
        Q_PROPERTY(int startDragDistance READ startDragDistance NOTIFY startDragDistanceChanged FINAL)
        Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL)
        Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL)
        Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL)
        Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL)
        Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL)
        Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL)
        Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL)
        Q_PROPERTY(int mouseQuickSelectionThreshold READ mouseQuickSelectionThreshold WRITE setMouseQuickSelectionThreshold NOTIFY mouseQuickSelectionThresholdChanged FINAL)
        Q_PROPERTY(int mouseDoubleClickDistance READ mouseDoubleClickDistance STORED false CONSTANT FINAL)
        Q_PROPERTY(int touchDoubleTapDistance READ touchDoubleTapDistance STORED false CONSTANT FINAL)

  • Moderators

    Right, I was mislead by QProperty and passworddelay. It's Q_PROPERTY and passwordMaskDelay. See my response above for solution.

  • Thanks Chris. can You mark it as solved? idk how

  • Moderators

    I'm glad I could help. You can mark the topic as solved from the "topic tools" menu on the right side of your post. See Hitchhiker's Visual Guide to the Qt Forum for help.

Log in to reply