[PyQt] modifying a Qt Class: how to get the equivalent of macro Q_D in PyQt?

Andreas Pakulat apaku at gmx.de
Thu Jun 25 16:38:15 BST 2009


On 25.06.09 17:03:47, TP wrote:
> Hi everybody,
> 
> I have subclassed QComboBox. For example I have changed paintEvent to get a
> customized look. It works perfectly. But I have also to change the behavior
> of the mouse wheel on the combo box. For this, I would like to subclass the
> function wheelEvent of QComboBox (see below its C++ source code, you can
> find it in the Qt source code in the directory
> src/gui/widgets/qcombobox.cpp).
> 
> This function seems easy to understand and subclass, except for one thing:
> the macro Q_D creates a pointer d. How to do the same thing in PyQt? What
> is the PyQt equivalent of Q_D?

You can't do that, you can't even use that inside a C++ subclass of
QComboBox, because the dpointer is private to the QComboBox, so only
friends of that class can use it.

Long story short: If you want to do the same as the normal wheelEvent plus
something additional then just call the original wheelEven from your subclass.

Andreas

-- 
You will be the victim of a bizarre joke.


More information about the PyQt mailing list