QxClassX::create

Forum for posting problems using QxOrm library

QxClassX::create

Postby jimmytaker » Tue Dec 27, 2016 4:13 am

How do you do this:
Code: Select all
boost::any_cast<IxModel*>(
            QxClassX::create(QStringLiteral("mv::%1_model").arg(model->getClass()->getKey())));

The object gets created, but it cannot get cast to IxModel.
The line will not work, because the model is of a type derived from IxModel, however boost::any_cast will only cast to the actual class, not a parent class.

I can use:
Code: Select all
qobject_cast<IxModel*>(model->cloneModel());

And then clean it up and do what I want, but should it not be possible to create a new object somehow?

Edit:
Code: Select all
ixm2->clear();
ixm2->setParentModel(Q_NULLPTR);
ixm2->qxFetchAll();

This is how I try resetting it, however even though it contains the items that it should, this model has issues. E.g. when I create a nested model from it, and add an item to that nested model, and try
Code: Select all
ixm2->qxSaveRow(row, "the nesting relation");

the relation does not get saved. Trying the same thing with a model created with "new" works as intended.
So now the question is even more relevant.
jimmytaker
 
Posts: 19
Joined: Fri Dec 23, 2016 11:04 pm

Re: QxClassX::create

Postby jimmytaker » Wed Dec 28, 2016 6:44 am

FIXED.
Just used
Code: Select all
IxModel* ix = qx::create_nude_ptr<IxModel>("MyModel");

and it works like a charm. Beware the possible memLeak ;)
jimmytaker
 
Posts: 19
Joined: Fri Dec 23, 2016 11:04 pm

Re: QxClassX::create

Postby qxorm » Fri Feb 24, 2017 9:52 am

FIXED.

Great !
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron