[Interest] adapting a QMenu's width in a QStyle?

René J.V. Bertin rjvbertin at gmail.com
Tue Jun 7 23:02:51 CEST 2016


On Tuesday June 07 2016 20:21:58 Sergio Martins wrote:

> How are you setting this bounding rectangle ?

Ahem :) I hadn't discovered that yet when I (finally) posted this question. I'm not writing a QStyle from scratch, but making some changes to QtCurve.

> Have you tried reimplementing QStyle::sizeFromContents() and handling 
> QStyle::CT_Menu ?

I indeed have now found the appropriate case in sizeFromContents() to add the required compensation (extra width) I was looking to add. That's not the CT_Menu case, but CT_MenuItem. Or maybe I could collect all the required information while handling CT_MenuItem cases until I can use (and reset) the data in the next CT_Menu case. I haven't experimented with that, just adding the extra width for CT_MenuItem works well enough for now.

Thanks in any case!

R.



More information about the Interest mailing list