1

I have an apllication that need an object

the object type is QgsSymbolV2

but i cannot do that :

QgsSymbolV2 * lSymbol = new QgsSymbolV2();

because in the class qgssymbolv2 there is no constructor it is a pure static class, but in the old version ( qgsi 1.6 by example ) the class qgissymbol has 3 types of constructor with different parameters and a default constructor

so my idea is to build my class CMyQgisSymbol by exemple in order to add some fonction that my application needs but my class must be instanciate by a new and must be based or herit of the qgssymbolv2 class

i try this code : in my header file :

class CMyQgsSymbol : public QgsSymbolV2
{
public :
    CMyQgsSymbol();
    ~CMyQgsSymbol();
}

in my source file :

lSymbol = new CMyQgsSymbol();

but when i build the code i have this error :

cannot allocate an object of abstract type

How can I proceed to create this object?

1 Answer 1

1

In your parent class you have some virtual functions and it is an abstract class (so you can't create objects from that class).

So you have to implement them in your child class.

Here you have a nice explanation of virtual functions.

1
  • finally i use a different way, i use this : QgsSymbolV2 * newsymbol = QgsSymbolV2::defaultSymbol(QGis::GeometryType)
    – ainardi
    Jul 30, 2015 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.