开发者

changing size of Widget from QStyle

I am writting a QStyle Here I am changing th开发者_如何转开发e QProgressBar to a Slim single line, no text. So Height will also be reduced to 5px. However Widget Width will be determined by layout. what should I do in My Style's drawControl to change widget height ?


I've never actually written a QStyle but I would consider it odd if you were supposed to resize anything inside drawControl. I could be wrong on this by a quick review of the documentation would seem to suggest that you would override subElementRect and return a rect based on current width and your preferred height. I assume this would be called by layout activities and would be sorted out by the time drawControl gets called.


Do you need the height for the widget to be fixed? Or just the drawn height to never go past 5 pixels? For the first, set the height and resize policy on the polish function. For the second, override the drawing in the QStyle to only use 5 pixels. The functions that do the drawing generally take rects; you can call the base class's draw with a modified rect if you properly override the appropriate functions. Unfortunately, it's been years since I've done any QStyle work, so I'm not sure exactly what those functions are.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜