QTabWidget tabs on the vertical, but text in horizontal
Asked Answered
K

3

15

I'm trying to make an app in C++ Qt with a sidebar like this one:

Finder's sidebar

But when making QTabWidget's orientation to West, it makes the text vertical. How to have the text on the left, but horizontally-aligned? Ps: I don't need icons. Thanks in advance.

Kerns answered 13/1, 2013 at 1:8 Comment(0)
S
9

You can use QListWidget to show the "tabs" (with some mods to make it look like you want) and QStackedWidget to handle switching between pages like normal tab widget does.

Silvas answered 13/1, 2013 at 1:34 Comment(5)
I did tried the QListWidget approach, but how do I make it look like that? Stylesheets? I don't see as much customizing power there...Imbalance
If you don't need icons, what do you need to customize? Remove borders and change background and make a highlight gradient? That should be doable with stylesheets.Silvas
I solved it with the following stylesheet: pastebin.com/6UqpixtQ, many thanks to you!Imbalance
Is the solution available somewhere else? pastebin has removed it , as it it is too old now.Misusage
it would be nice to get stylesheet from somewhere??Mayest
S
3

A bit of "advertising" for a WTFPL implementation here on assembla Any contribution will be much appreciated.

exemple1 exemple2 exemple3

Sigma answered 23/4, 2013 at 9:6 Comment(0)
Z
1

use QProxyStyle, this function will rotate 180 for text, and you can rotate 90。

void MyProxyStyle::drawItemText( QPainter* painter,
                                 const QRect&,
                                 int alignment,
                                 const QPalette& palette,
                                 bool enabled,
                                 const QString& text,
                                 QPalette::ColorRole textRole ) const
{
    painter->save();
    painter->translate(160,50);
    painter->rotate(-180);

    QCommonStyle::drawItemText( painter,
                                rectangle,
                                alignment,
                                palette,
                                enabled,
                                text,
                                textRole );

    painter->restore();
}
Zug answered 9/6, 2013 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.