Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
silajim
Posts: 27
Registered: ‎10-14-2013
My Device: Z10

Re: Cannot define extra object on ApplicationUI.hpp

Zmey I cleaned the project several times.

 

greenmr Here is the code:

 

ApplicationUi::ApplicationUi()

 

 

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
 :QObject(app)
{
	//prepare the localization
	myTranslator = new QTranslator(this);
	myLocaleHandler = new LocaleHandler(this);
		if(!QObject::connect(myLocaleHandler,
	     			SIGNAL(systemLanguageChanged()),
	     			this,
	     			SLOT(onSystemLanguageChanged()))){
	     		qWarning() << "Recovering from a failed connect()";
	     	}
	     	onSystemLanguageChanged();
	     	//_settings = new Settings(this);
	     	qDebug()<< "1";
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qDebug()<< "2";
    _notes = new Notes(this);
    qDebug()<< "3";
    qml->setContextProperty("_app",this);
    qDebug()<< "10";
    // create root object for the UI
    qml->createRootObject<AbstractPane>();
    qDebug()<< "11";
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    qDebug()<< "8";
    // set created root object as a scene
     app->setScene(root);
     qDebug()<< "9";
     _calendar = new Calendar(this);

     QGeoPositionInfoSource *source =
     			QGeoPositionInfoSource::createDefaultSource(this);

     	if (source) {
     		bool positionUpdatedConnected = connect(source,
     				SIGNAL(positionUpdated (const QGeoPositionInfo &)), this,
     				SLOT(positionUpdated (const QGeoPositionInfo &)));

     		if (positionUpdatedConnected) {
     			source->requestUpdate();
     		} else {
     			qDebug() << "positionUpdated connection failed";
     		}
     	} else {
     		qDebug() << "Failed to create QGeoPositionInfoSource";
     	}
}

 

And the main() :

 

Q_DECL_EXPORT int main(int argc, char **argv)
{
    // this is where the server is started etc
    qmlRegisterUncreatableType<EventEditor>("com.example.College_Notes", 1, 0, "EventEditor", "Usage as property type and access to enums");
    qmlRegisterUncreatableType<Notes>("com.example.College_Notes", 1, 0, "Notes", "Usage as property type and access to enums");
    qmlRegisterType<EventViewer>();
    qmlRegisterType<Calendar>();
	qmlRegisterType<Notes>();
	qmlRegisterType<Profile>();
	qmlRegisterType<ProfileEditor>();
	qmlRegisterType<RegistrationHandler>();
	qmlRegisterType<ImageLoader>();
	qmlRegisterType<NoteEditor>();
    // this is where the server is started etc
	qDebug() << "Starting here";
	qDebug() << "Flurry Version: " << Flurry::Analytics::GetFlurryAgentVersion();
	Flurry::Analytics::SetDebugLogEnabled(true);
	Flurry::Analytics::SetAppVersion(bb::ApplicationInfo().version());
	Flurry::Analytics::StartSession("MB7BSJXNG3H62JD2JN5Z");
	Flurry::Analytics::LogEvent("App Started");
    Application app(argc, argv);

    // localization support
    QTranslator translator;
    QString locale_string = QLocale().name();
    QString filename = QString( "College_Notes_%1" ).arg( locale_string );
    if (translator.load(filename, "app/native/qm")) {
       app.installTranslator( &translator );
    }

    new ApplicationUI(&app);

    // we complete the transaction started in the app constructor and start the client event loop here
    return Application::exec();
    // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
}

 

 I hope it helps.

 

Developer
greenmr
Posts: 919
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Cannot define extra object on ApplicationUI.hpp

[ Edited ]

I don't know if this is the problem, but one thing I see in your main() is that you register a bunch of classes without specifying how they should be registered. I could be wrong, but I don't believe this is valid. You also register Notes twice, both as a regular type and also as an uncreatable type. You need to pick one or the other.

 

I also doubt that you really want EventEditor to be uncreatable since this is normally only used for things like type constants.

 

Try changing your registrations like this:

 

qmlRegisterType<EventEditor>("com.example.College_Notes", 1, 0, "EventEditor");
qmlRegisterType<EventViewer>("com.example.College_Notes", 1, 0, "EventViewer");
qmlRegisterType<Calendar>("com.example.College_Notes", 1, 0, "EventEditor");
qmlRegisterType<Notes>("com.example.College_Notes", 1, 0, "Notes"); qmlRegisterType<Profile>("com.example.College_Notes", 1, 0, "Profile"); qmlRegisterType<ProfileEditor>("com.example.College_Notes", 1, 0, "ProfileEditor"); qmlRegisterType<RegistrationHandler>("com.example.College_Notes", 1, 0, "RegistrationHandler"); qmlRegisterType<ImageLoader>("com.example.College_Notes", 1, 0, "ImageLoader"); qmlRegisterType<NoteEditor>("com.example.College_Notes", 1, 0, "NoteEditor");

 

 

 



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
New Developer
silajim
Posts: 27
Registered: ‎10-14-2013
My Device: Z10

Re: Cannot define extra object on ApplicationUI.hpp

Nope! that thing does not work it crashes at build.

 

I don't know why, but the problem seemed to be the _profile, i was never initialized. I will tell you more in some hours, after i check all the application. 

 

 

Developer
greenmr
Posts: 919
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Cannot define extra object on ApplicationUI.hpp

Ok, keep us posted and we'll try to help where we can.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.