Personal tools
You are here: Home Forum Extension of the platform How could DataObject read DataModel QLists

How could DataObject read DataModel QLists

Up to Extension of the platform

How could DataObject read DataModel QLists

Posted by Timo Siltala at April 14. 2017

I followed the DataObject naming method used in Atomic example. It works fine with a few QLists in DataModel, but having lots of them make life very complicated due to enormous long Constructor calls having pointers to all of them. I tried to access DataModel's QLists from DataObject::name() and few other methods but compiler error messages indicates that the DataModel data structures don't yet exist when for example DataObject::name is called, so it fails. Also it is impossible to copy the DataObject constructor because the only difference between overloaded constructors would be the pointer, which isn't enough and can't be compiled. Not knowing in which order different methods are called when DataModel and DataObjects are set up in execution makes it very difficult to guess other possibilities. Any hits would be most appreciated.

Best regards, Timo

Re: How could DataObject read DataModel QLists

Posted by Timo Siltala at April 16. 2017

If you have the same problem, this is the way I solved it. Surely the most elegant way but working:

-Create a pointer to your DataModel: MYMODULE_DataModel* myDataModel;
-Assign it the address of your DataModel where ever you create it (usually probably in MYMODULEGUI):

   CAM_DataModel* MYMODULEGUI::createDataModel() // Create custom data model
   {
       return new MYMODULEGUI_DataModel( this );
   }

Now you can use it in your DataObject constructor:

   MYMODULE_DataObject::MYMODULE_DataObject(...,MYMODULEGUI_DataModel* dm, ...)

And use it as pointer in DataObject name for example:

    QString m=dm->WhateverQList[i].parameter;

Hopefully this helps you if you are strugling with the access problems.

Timo

Powered by Ploneboard
Document Actions