[PyKDE] crash: pure virtual function called
Jim Bublitz
jbublitz at nwinternet.com
Tue Nov 12 23:44:00 GMT 2002
On 12-Nov-02 marvelan L wrote:
> I have built an application with Qt 3.0.4 and PyQt 3.4.
>>From time to time I get a error message on stdout
> saying "pure virtual function call" and then abort is called
> and the program exits.
> I suspect that this is from the PyQt bindings. Have anyone
> seen this and know what to do about it?
Check the *Qt* docs and see if either:
1. One of the classes you're using is "abstract"
2. A method in a class you're using ends in " = 0", for example:
virtual int someMethod (QWidget *parent) = 0;
(2) is an example of a pure virtual function. When a method like
(2) exists in a class, the class is abstract. When the class is
abstract, you can't instantiate it. You have to subclass the
abstract class and overload *all* of the pure virtual functions,
so for example:
C++ (Qt):
--------
class SomeAbstractClass
{
public:
...
virtual int someMethod (QWidget *parent) = 0;
...
};
Python (your program):
---------------------
class SomeClass (SomeAbstractClass):
...
def someMethod (self, parent):
<do something here because the
pure virtual method probably
doesn't do anything>
...
and def EVERY pure virtual function in the abstract class (usually
there are only a few at most, possibly only one).
If neither 1 or 2 is true, then you'll need to provide more
information about what your program is doing.
Jim
More information about the PyQt
mailing list