开发者

Is it possible to style individual tab bars?

开发者 https://www.devze.com 2022-12-31 13:48 出处:网络
I would like to style individual tabs of the tab bar of a QTabWidget (not hover or current but an individual one)WHY? because I need to get the user\'s attention so that he knows开发者_高级运维 urgent

I would like to style individual tabs of the tab bar of a QTabWidget (not hover or current but an individual one) WHY? because I need to get the user's attention so that he knows开发者_高级运维 urgent information appeared in that tab. There can be multiple tabs that need attention.


You would have to assemble your own tab widget but i think if you subclass QTabBar and use setTabButton(int index, ...) you can set a custom widget for the item in the tab, this would let you control the behaviour and you could change it through code or style it via the property selector e.g.

QTabBar MyButtonWidget[showalert=true] 
{
   background-color: red;
}


This seems a little strange. Why don't you start with that tab selected?

I don't think you can do that with stylesheets. You can easily customize first and last but not any tab (AFAIK)

http://doc.qt.io/archives/4.6/stylesheet-reference.html

On the other hand you can set custom icon to draw attention or use void QTabBar::setTabTextColor ( int index, const QColor & color )


You might want to try simply using stylesheets to directly style a tab instead of subclassing just for that purpose. In the stylesheet, you can use the :tab subcontrol to access a single tab, and you can then modify a dynamic propoerty to set its state as either needing attention or not, and applying the style based on the dynamic property.

See : :tab sub control , Customizing using dynamic properties

0

精彩评论

暂无评论...
验证码 换一张
取 消