Unsolved Left align TabBar on Mac OSX
-
I can't comment on that.
It was really curiosity about your use case.
Might be a silly question but did you already checked the QTabBar part of the style sheet documentation ?
-
Hi
tryQTabWidget::tab-bar { left: 0; }
-
@SGaist said in Left align TabBar on Mac OSX:
Might be a silly question but did you already checked the QTabBar part of the style sheet documentation ?
Yes, I tried all the options and they are working on Windows. Not on Mac though
@mrjj said in Left align TabBar on Mac OSX:
Hi
tryQTabWidget::tab-bar { left: 0; }
Not working :(
-
@Taytoo
ok then i assume stylesheets cannot do it on OSX. -
@mrjj The suggestion give in the stackoverflow answer i.e. use QStyle, how would that work? if I have stylesheet applied to the Tab, would QStyle conflict with it?
-
@Taytoo
Hi
The QStyle is the backbone of drawing the widgets. It does respect stylesheets in most cases.There is also https://doc.qt.io/qt-5/qproxystyle.html
which is often used for this kind of override.Its something like
https://stackoverflow.com/questions/29835759/qt-custom-qstyle-for-qtabbar
but its not full sample you have to fiddle with it to get it to move the actual tab positions. -
Can anyone provide an example of how to use QProxyStyle to set tab alignment to left on macOS? I've never worked with QProxyStyle so finding it hard to figure this stuff out, even from documentation
-
-
@Taytoo
HiIn theory, we should be able to do
class TabStyle : public QProxyStyle { public: explicit TabStyle(Qt::Orientation orientation, QStyle *baseStyle = 0) : QProxyStyle(baseStyle) {} virtual int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const override { if (stylehint == SH_TabBar_Alignment ) return Qt::AlignLeft; // or right return QProxyStyle::styleHint(stylehint, opt, widget, returnData); } };
However, i could not get it to RIGHT align on Windows so it seems Tabbar ignores it.
https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qtabbar.cpp.html
It goes
void QTabBarPrivate::layoutTabs() { Q_Q(QTabBar); .... Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));
So it seems it should use the hint but my styleHint seems not to have any effect on
the tab alignment at all.
(always left, regardless of center or right)So im a bit lost but Im using a tab widget and maybe its the reason it get ignored but
as far as i know, it's using a tabbar internally. -
@mrjj That's what I read online on stackoverflow as well and that particular author suggested modifying qt sources and rebuilding, but i don't know how to do this.
Anyone has any idea why qproxystyle isn't working?