How do you create an Object of QStyleHints
-
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.
-
Yup,
QGuiApplication::styleHints()->passwordMaskDelay()
. -
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.
-
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
-
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 { public: 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 else return QProxyStyle::styleHint(hint, option, widget, returnData); } };
and set it on the application eg.
... QApplication a(argc, argv); a.setStyle(new MyStyle(a.style())); ...
-
#ifndef QSTYLEHINTS_H #define QSTYLEHINTS_H #include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE class QPlatformIntegration; class QStyleHintsPrivate; class Q_GUI_EXPORT QStyleHints : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QStyleHints) 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) public:
-
Right, I was mislead by
QProperty
andpassworddelay
. It'sQ_PROPERTY
andpasswordMaskDelay
. See my response above for solution. -
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.