Page 1 of 1

QxClassX::create

PostPosted: Tue Dec 27, 2016 4:13 am
by jimmytaker
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.

Re: QxClassX::create

PostPosted: Wed Dec 28, 2016 6:44 am
by jimmytaker
FIXED.
Just used
Code: Select all
IxModel* ix = qx::create_nude_ptr<IxModel>("MyModel");

and it works like a charm. Beware the possible memLeak ;)

Re: QxClassX::create

PostPosted: Fri Feb 24, 2017 9:52 am
by qxorm
FIXED.

Great !