Hi,

as far as I know we do not support direct loading from Qt resources via IOUtil. 
If you want to load a resource you can use our own resource system, though:

- Use one of the overloads of Load() that takes a us::ModuleResource instead of 
a path, e. g.:

auto myStl = IOUtil::Load<Surface>(resource); // myStl is a 
mitk::Surface::Pointer

- Where resource (us::ModuleResource) is typically loaded like:

#include <usGetModuleContext.h>
#include <usModuleResource.h>

auto resource = us::GetModuleContext()->GetModule()->GetResource("my_stl.stl");

If you call GetModule() from another module that does not contain the resource, 
you need to pass the name of the module to GetModule() like 
GetModule("MitkMyModule").

To have the resource in your module in the first place, add the following to 
your module's files.cmake:

set(RESOURCE_FILES my_stl.stl) # Or, if there are already resources, add 
my_stl.stl to the list.

The file is expected to be located in "Resources/my_stl.stl".

You find plenty of examples in the MitkSegmentation module.

Best,

Stefan
________________________________________
Von: Mujassim Jamal <mujassimjama...@gmail.com>
Gesendet: Dienstag, 15. April 2025 06:45
An: mitk-users@lists.sourceforge.net
Betreff: [Extern] - [mitk-users] Loading STL from Plugin Resource

Hello again,

I’ve created a plugin and would like to load an STL file located in
the 'resources/stl' folder within the plugin. I'm attempting to load
the STL by passing the resource path (e.g.,
:/org.mitk.customplugin/stl/my_stl.stl) to
'mitk::IOUtil::Load<mitk::Surface>'.

However, I'm getting the following error:
"Description File: :/org.mitk.customplugin/stl/my_stl.stl does not exist"

The strange part is that when I check the resource using
'QFile::exists', it confirms that the file exists. Could this be an
issue with 'IOUtil::Load' not supporting Qt resource file paths?

Thanks for any help!

Best,
Mujassim


_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users


_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to