2013-01-13 76 views
9

我试图在C++的Qt的应用程序,像这样一个侧边栏:QTabWidget标签,但文字水平

Finder's sidebar

但要做出QTabWidget的方向,使西时,它使文字垂直。如何在左侧有文字,但水平对齐? Ps:我不需要图标。提前致谢。

回答

7

您可以使用QListWidget来显示“选项卡”(使用某些模式使其看起来像您想要的),并使用QStackedWidget来处理页面之间的切换,如常规选项卡窗口小部件所做的那样。

+0

我没试过QListWidget方法,但如何使它看起来像那样?样式表?我没有看到那么多的定制能力...... –

+0

如果你不需要图标,你需要定制什么?删除边框并更改背景并制作高光渐变?这应该可以通过样式表来实现。 – Eugene

+0

我用下面的样式表解决了它:http://pastebin.com/6UqpixtQ,非常感谢你! –

1

使用QProxyStyle,此功能将文本旋转180,并且可以旋转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(); 
}