QIconEngine virtual_hook() support

Phil Thompson phil at riverbankcomputing.com
Tue Sep 2 10:15:10 BST 2025


On 02/09/2025 01:46, Maurizio Berti wrote:
> QIconEngine does not support virtual_hook().
> 
> At this time, this is not a huge problem with Qt6, as they made 
> isNull()
> and scaledPixmap() virtual since 6.0.
> Yet, I also realize that Qt5 is fundamentally EOL (but we know it's 
> still
> in use), but I also think that we cannot exclude the possibility of 
> future
> Qt6/7 versions that may add further hooks (who knows, maybe they may 
> want
> to add support for emojis in QIcon - I actually thought about that) 
> while
> "forgetting" related virtual functions again in the meantime, unless 
> they
> decide to drop the virtual_hook approach to begin with.
> 
> I don't have enough C++/sip knowledge to understand if there may be
> limitations from the Python perspective, but, if there aren't, would it 
> be
> possible to add virtual_hook() to Qt6 (and, possibly, Qt5 as well)?
> 
> If it's not possible for specific C++/Python technical reasons, I'd 
> still
> be curious to know the reason, just for the sake of understanding.

It's technically possible, but why would you want it? The API is there 
if you (not Qt) want to implement your own QIconEngine sub-class in 
Python and want to override the current hook implementations. Do you?

If Qt wanted to add a new feature while retaining binary compatibility 
they would add an appropriate non-virtual API call which would be 
implemented by calling a new hook. PyQt would then just wrap the new API 
call.

Phil


More information about the PyQt mailing list