[vtkusers] vtkInteractorStyleImage and QT Widget

Alesssandro notinmyhead at gmail.com
Tue Sep 4 09:38:45 EDT 2012


Il giorno 04/set/2012, alle ore 15.06, David Doria ha scritto:

> On Tue, Sep 4, 2012 at 8:57 AM, Ale <notinmyhead at gmail.com> wrote:
>> sorry I miss the attachment...
>> #ifndef CUSTOMWIDGET_H
>> #define CUSTOMWIDGET_H
>> 
>> #include <QWidget>
>> 
>> /* include custom Interactor */
>> #include "custominteractorstyle.h"
>> 
>> namespace Ui {
>>    class CustomWidget;
>> }
>> 
>> class CustomWidget : public QWidget
>> {
>>    Q_OBJECT
>> 
>> public:
>>    explicit CustomWidget(QWidget *parent = 0, vtkImageData * image = NULL, QString wtitle = QString::null);
>> 
>>    ~CustomWidget();
>> 
>>  ...
>> 
>> public slots:
>>  ...
>> 
>> protected:
>>   ...
>> 
>> private:
>>    Ui::CustomWidget *ui;
>> 
>>  ....
>> 
>> };
>> 
>> #endif //CUSTOMWIDGET_H
>> 
>> 
>> #ifndef CUSTOMINTERACTORSTYLE_H
>> #define CUSTOMINTERACTORSTYLE_H
>> 
>> #include <QWidget>
>> 
>> #include "customwidget.h"
>> 
>> class CustomInteractorStyle : public vtkInteractorStyleImage
>> {
>> public:
>>    CustomInteractorStyle ();
>> 
>>    static CustomInteractorStyle * New();
>>    vtkTypeMacro(CustomInteractorStyle, vtkInteractorStyleImage)
>> 
>> protected:
>> 
>>    std::vector < CustomWidget * > widgets;
>> 
>> public:
>>    ...
>> 
>> private:
>>   ...
>> 
>> protected:
>>    virtual void OnKeyDown();
>>    virtual void OnMouseWheelBackward();
>>    virtual void OnMouseWheelForward();
>>    virtual void OnRightButtonDown();
>> };
>> 
>> vtkStandardNewMacro(CustomInteractorStyle)
>> 
>> #endif // CUSTOMINTERACTORSTYLE_H
> 
> In CustomInteractorStyle.h, you should forward declare CustomWidget.
> That is, replace this line:
> 
> #include "customwidget.h"
> 
> with
> 
> class CustomWidget;

If I do so, I get (as I would expect) an error like that: error: invalid use of incomplete type 'struct CustomWidget' each time the code point to a public member of the CustomWidget...

I'd like to provide you a compilable file but they are extracted from a very huge project so unfortunately it'll take time...  

Alessandro




More information about the vtkusers mailing list