[Qt4-preview-feedback] Ability to read the border and padding properties of styled widgets
Craig Scott
craig.scott at csiro.au
Sun Mar 1 23:02:39 CET 2009
I understand there's no API and that it's not currently in the roadmap,
but consider widgets that need to reimplement their sizeHint() function.
A good example of a motivating case is a QLabel with word wrapping
enabled. The sizeHint() changes depending on what horizontal constraints
are placed on the widget. While it could be argued that the size hint
specifies what the widget wants in an unconstrained world, it still
makes sense (to me at least) that if it can be told about its
constraints then it should be able to give the best possible size hint.
If the width is constrained such that the label has to wrap, then the
sizeHint() should have a deeper height to reflect this. I would have
thought that this particular example would occur frequently enough to
warrant some consideration. At the moment, if a widget's style sheet
contains non-zero padding or borders, there is no way for a
reimplemented sizeHint() to know about it and therefore it is not
possible to account for it.
Olivier Goffart wrote:
> On Friday 27 February 2009 14:48:08 Craig Scott wrote:
>> Hi. It would seem that there is still no way to programmatically obtain
>> the padding and border widths that are in effect on a widget. You can
>> specify them with a stylesheet but you cannot read those values in code,
>> at least not as far as I can tell from the documentation. Has this
>> situation been addressed for 4.5 (or have I just missed it)? I seem to
>> recall this deficiency being mentioned many months back but I can't
>> track down whether it was through Trolltech support or just a forum
>> posting. Apologies if I'm just not looking in the right places. ;)
>
> Hi,
>
> There is no public API to access stylesheet properties.
> (And this is not in the roadmap)
>
> If your widget inherit from QFrame, you may be able access the border by the
> frameWidth property.
>
>
> _______________________________________________
> Qt4-preview-feedback mailing list
> Qt4-preview-feedback at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback
--
Dr Craig Scott
Computational Modeling Group, CSIRO (CMIS)
Melbourne, Australia
Ph: 61-3-86013809 (Docklands)
Ph: 61-3-95458096 (Clayton)
More information about the Qt4-feedback
mailing list