What should I return in stylehint()?
-
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? -
@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.?@Tomi
Since I assume this is for aQTabBaryou 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. -
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?@Tomi
You look that up for thehint == QStyle::SH_Slider_AbsoluteSetButtonscase you are covering. So https://doc.qt.io/qt-6/qstyle.html#StyleHint-enum :QStyle::SH_Slider_AbsoluteSetButtons64 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::RightButtonfrom your return value. -
@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.?@Tomi
Since I assume this is for aQTabBaryou 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.