[vtkusers] return vtkSmartPointers from a function or signal/slot
Miro Drahos
mdrahos at robodoc.com
Wed Aug 14 12:45:53 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>);
The idea is to send off the signal with something like
emit doneSurfaceProcessing(myclass->getSurface());
then the slot would be
setSurface(???) //vtkSmartPointer<T> or T* or T& ?
Thank you!!
Miro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130814/e18bac79/attachment.htm>
More information about the vtkusers
mailing list