Abstract type with qmlRegisterType
-
Hi, I've been using abstract classes with QML, and it has been working great until I tried to register a new type, then I get:
error: cannot allocate an object of abstract type ‘QDeclarativePrivate::QDeclarativeElement<IsAnalogIn>’
This is easy enough to work around by giving my abstract class an implementation, but that is a hack. Is this a fundamental limitation, or is there something I can do to make this work?
-
I haven't tried but you may be able to register the abstract class using
"qmlRegisterTypeNotAvailable":http://doc.qt.nokia.com/4.7/qdeclarativeengine.html#qmlRegisterTypeNotAvailable -
Hi, I have the same problem with you now,can you give me some idea to solve this problem .Thanks !
instantiated from ‘int qmlRegisterType(const char*, int, int, const char*) [with T = Directory]’
error: cannot allocate an object of abstract type ‘QDeclarativePrivate::QDeclarativeElement<Directory>’
note: because the following virtual functions are pure within ‘QDeclarativePrivate::QDeclarativeElement<Directory>’: -
Hi, I have the same problem with you now,can you give me some idea to solve this problem .Thanks !
instantiated from ‘int qmlRegisterType(const char*, int, int, const char*) [with T = Directory]’
error: cannot allocate an object of abstract type ‘QDeclarativePrivate::QDeclarativeElement<Directory>’ note: because the following virtual functions are pure within ‘QDeclarativePrivate::QDeclarativeElement<Directory>’: -
I'm not sure but you also can try "qmlRegisterUncreatableType":http://doc.qt.nokia.com/4.7/qdeclarativeengine.html#qmlRegisterUncreatableType
-
thanks,I have used qmlRegisterUncreatableType ,but the problem can't be solved! Could you give me other idea!thanks
#ifdef NO_DIRECTORYS_ALLOWED
qmlRegisterUncreatableType<Directory>("Charts",1,0,"Directory","Get back to work, slacker!");
#else
qmlRegisterType<Directory>( "Charts", 1, 0, "Directory" );
#endif -
changli85, qmlRegisterUncreatableType should work for abstract classes. Can you elaborate what error do you have, what is Directory class, when this define is defined?