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. What should I return in stylehint()?
Forum Updated to NodeBB v4.3 + New Features

What should I return in stylehint()?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 414 Views
  • 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
    Tomi
    wrote on last edited by
    #1

    Hi,

    I have an example:

    class MyStyle : public QProxyStyle
    {
    public:
        using QProxyStyle::QProxyStyle;
    
        int styleHint(QStyle::StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const
        {
            if (hint == QStyle::SH_Slider_AbsoluteSetButtons)
                return (Qt::LeftButton | Qt::MidButton | Qt::RightButton);
            return QProxyStyle::styleHint(hint, option, widget, returnData);
        }
    };
    

    In docs:

    Returns an integer representing the specified style hint for the given widget described by the provided style option.
    

    But what is Qt::LeftButton | Qt::MidButton | Qt::RightButton ? I know there are mouse buttons, but why I returned them? How to know what I should to return?

    JonBJ 1 Reply Last reply
    0
    • T Tomi

      @JonB Thank you. But what I should return for example for "QStyle::SH_TabBar_ElideMode"
      QStyle::SH_TabBar_ElideMode 67 The default eliding style for a tab bar.?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #4

      @Tomi
      Since I assume this is for a QTabBar you would look through its documentation page and come across elideMode : Qt::TextElideMode and therefore enum Qt::TextElideMode. I did that by searching around and you would need to do the same.

      1 Reply Last reply
      3
      • T Tomi

        Hi,

        I have an example:

        class MyStyle : public QProxyStyle
        {
        public:
            using QProxyStyle::QProxyStyle;
        
            int styleHint(QStyle::StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const
            {
                if (hint == QStyle::SH_Slider_AbsoluteSetButtons)
                    return (Qt::LeftButton | Qt::MidButton | Qt::RightButton);
                return QProxyStyle::styleHint(hint, option, widget, returnData);
            }
        };
        

        In docs:

        Returns an integer representing the specified style hint for the given widget described by the provided style option.
        

        But what is Qt::LeftButton | Qt::MidButton | Qt::RightButton ? I know there are mouse buttons, but why I returned them? How to know what I should to return?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @Tomi
        You look that up for the hint == QStyle::SH_Slider_AbsoluteSetButtons case you are covering. So https://doc.qt.io/qt-6/qstyle.html#StyleHint-enum :

        QStyle::SH_Slider_AbsoluteSetButtons 64 Which mouse buttons cause a slider to set the value to the position clicked on.

        So in this case clicking any of those 3 specific mouse buttons will cause the slider take the position clicked on. If, say, you decided you want to use right-click on slider for some other purpose you would remove Qt::RightButton from your return value.

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

          @JonB Thank you. But what I should return for example for "QStyle::SH_TabBar_ElideMode"
          QStyle::SH_TabBar_ElideMode 67 The default eliding style for a tab bar.?

          JonBJ 1 Reply Last reply
          0
          • T Tomi

            @JonB Thank you. But what I should return for example for "QStyle::SH_TabBar_ElideMode"
            QStyle::SH_TabBar_ElideMode 67 The default eliding style for a tab bar.?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @Tomi
            Since I assume this is for a QTabBar you would look through its documentation page and come across elideMode : Qt::TextElideMode and therefore enum Qt::TextElideMode. I did that by searching around and you would need to do the same.

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

              @JonB Thank you :)

              1 Reply Last reply
              0

              • Login

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