[vtkusers] return vtkSmartPointers from a function and pass via signal/slot

Miro Drahos miroslav.drahos at ucsf.edu
Wed Aug 14 03:57:35 EDT 2013


Hi all,
I am having really hard times passing on reference to the objects that 
are stored as vtkSmartPointer<T> as private data within a class. E.g.:
class MyClass
{
   public:
     ...
    private:
     vtkSmartPointer<vtkPolyData> surface;
};

What is the best way to pass 'surface' via signal/slot mechanism of Qt?
I thought I'd create a public method
vtkPolyData * MyClass::getSurface() { return surface.GetPointer(); }
The problem is that GetPointer() returns *const* T* which the compiler 
complains about when I later want to use it. As a matter of fact, all 
vtkSmartPointer's public methods return const something.

What would be the preferred way to pass objects stored as 
vtkSmartPointer<T> object?
1.) T* MyClass::getT() const { return object.GetPointer(); }
2.) vtkSmartPointer<T> MyClass::getT() { return object; }
3.) something else?

I want to pass the object via signal/slot mechanism. What would be the 
best way?
A.) signal doneSurfaceProcessing(vtkPolyData &);
B.) signal doneSurfaceProcessing(vtkPolyData *);
C.) signal doneSurfaceProcessing(vtkSmartPointer<vtkPolyData>);

Thank you!!
Miro


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130814/614458e3/attachment.htm>


More information about the vtkusers mailing list