Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do you create an Object of QStyleHints
Forum Updated to NodeBB v4.3 + New Features

How do you create an Object of QStyleHints

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 770 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TomQue
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • T Offline
        T Offline
        TomQue
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          1
          • T Offline
            T Offline
            TomQue
            wrote on last edited by TomQue
            #5

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

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by Chris Kawa
              #6

              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.

              T 1 Reply Last reply
              0
              • Chris KawaC Chris Kawa

                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.

                T Offline
                T Offline
                TomQue
                wrote on last edited by TomQue
                #7

                @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

                1 Reply Last reply
                0
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by Chris Kawa
                  #8

                  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()));
                  ...
                  
                  1 Reply Last reply
                  2
                  • T Offline
                    T Offline
                    TomQue
                    wrote on last edited by
                    #9
                    #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:
                    
                    1 Reply Last reply
                    0
                    • Chris KawaC Offline
                      Chris KawaC Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        TomQue
                        wrote on last edited by
                        #11

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

                        1 Reply Last reply
                        0
                        • Chris KawaC Offline
                          Chris KawaC Offline
                          Chris Kawa
                          Lifetime Qt Champion
                          wrote on last edited by Chris Kawa
                          #12

                          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.

                          1 Reply Last reply
                          2

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved