[vtkusers] Smart Pointers with Qt with no includes?
Sensei
senseiwa at gmail.com
Tue Apr 9 10:22:03 EDT 2013
Dear all,
I am trying to use smart pointers in my code, which mixes Qt and VTK.
I'm afraid I am doing something really dangerous here.
First: I don't use CMake now, I need Xcode, and I can't change this
specification. This means one thing: qmake will not find VTK headers, so
I must use forward declarations.
The solutions I've found, for example in using a renderer, is declaring
a raw pointer:
class vtkRenderer;
class hMainWindow : public QMainWindow
{
// ...
vtkRenderer *renderer3d_;
};
In my code I'm using smart pointers as instructed, except that I need to
save the pointer for further uses:
void hMainWindow::setupRenderer3D()
{
// ...
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
// ...
renderer3d_ = renderer.GetPointer();
}
It seems that it's working, although since I've found no way of getting
the reference count of a smart pointer, I assume this is a disaster
waiting to happen.
I really hate including a lot of headers in my code, and as I said, I'd
like to avoid mixing Qt and VTK as much as possible.
What do you suggest? Ditching smart pointers in all my code?
Thanks!
More information about the vtkusers
mailing list