Qt-interest Archive, January 2008
QT4 and ProxyStyle pattern
Message 1 in thread
Hi,
I need to build a QLineEdit derived widget that haves a yellow
background when having the focus.
For performance reasons I cannot use stylesheets. So I see that I can
only use a custom-QStyle class.
I have found that the ProxyStyle pattern is the best solution available.
I have created a ProxyStyle class that forwards all the method to the
QStyle it is linked to.
After that, I created a FocusEnchancedStyle that inherits from
ProxyStyle, and only overloaded the drawPrimitive function, intercepting
the primitive PE_FrameLineEdit as suggested some time ago on this list.
in the default behaviour, the class forwards the drawPrimitive to
ProxyStyle...
But it doesn't work.
All the widgets are layed out wrongly, the dimensions are too big and
the widgets are in the wrong position.
In this context I have also seen that you cannot retrieve the style from
QApplication before a QApplication object is instantiated, but you can
set the style for it! It's really strange and, I am sure, not the wanted
behaviour.
A part for this, How can I solve the focus color issue?
Thank you in advance!
Regards,
ing. Federico Fuga
R&D consultant.
--
[ signature omitted ]