Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Designer Plugin for QVTKOpenGLWidget?



  • I am trying to make a designer plugin for the QVTKOpenGLWidget (it used to be there) but the designer crashes with the following error:

    ASSERT: "this->testAttribute(Qt::WA_NativeWindow) == false" in file /path/to/vtk/GUISupport/Qt/QVTKOpenGLWidget.cxx, line 222
    

    Note that I changed the path to vtk library in the error message to /path/to/vtk/. Any ideas on how to solve this?

    Here is my example code :

    Plugin header

    #ifndef QVTKOPENGLWIDGEPLUGIN_H
    #define QVTKOPENGLWIDGEPLUGIN_H
    
    #include <QtUiPlugin/QDesignerCustomWidgetInterface>
    
    class QVTKOpenGLWidgePlugin : public QObject, public QDesignerCustomWidgetInterface
    {
      Q_OBJECT
      Q_INTERFACES(QDesignerCustomWidgetInterface)
      Q_PLUGIN_METADATA(IID "com.ics.Qt.CustomWidgets")
    
    public:
      QVTKOpenGLWidgePlugin(QObject *parent = nullptr);
    
      bool isContainer() const;
      bool isInitialized() const;
      QIcon icon() const;
      QString domXml() const;
      QString group() const;
      QString includeFile() const;
      QString name() const;
      QString toolTip() const;
      QString whatsThis() const;
      QWidget *createWidget(QWidget *parent);
      void initialize(QDesignerFormEditorInterface *core);
    
    private:
      bool initialized;
    };
    
    #endif  // QVTKOPENGLWIDGEPLUGIN_H
    

    Plugin implementation

    #include "qvtkopenglwidgetplugin.h"
    #include <QVTKOpenGLWidget.h>
    
    QVTKOpenGLWidgePlugin::QVTKOpenGLWidgePlugin(QObject *parent) : QObject(parent)
    {
      initialized = false;
    }
    
    void QVTKOpenGLWidgePlugin::initialize(QDesignerFormEditorInterface * /* core */)
    {
      if (initialized)
        return;
    
      initialized = true;
    }
    
    bool QVTKOpenGLWidgePlugin::isInitialized() const
    {
      return initialized;
    }
    
    QWidget *QVTKOpenGLWidgePlugin::createWidget(QWidget *parent)
    {
      return new QVTKOpenGLWidget(parent);
    }
    
    QString QVTKOpenGLWidgePlugin::name() const
    {
      return "QVTKOpenGLWidget";
    }
    
    QString QVTKOpenGLWidgePlugin::group() const
    {
      return "VTK widgets";
    }
    
    QIcon QVTKOpenGLWidgePlugin::icon() const
    {
      return QIcon();
    }
    
    QString QVTKOpenGLWidgePlugin::toolTip() const
    {
      return "";
    }
    
    QString QVTKOpenGLWidgePlugin::whatsThis() const
    {
      return "";
    }
    
    bool QVTKOpenGLWidgePlugin::isContainer() const
    {
      return false;
    }
    
    QString QVTKOpenGLWidgePlugin::domXml() const
    {
      return "<ui language=\"c++\">\n"
             " <widget class=\"QVTKOpenGLWidget\" name=\"vtk_opengl_widget\">\n"
             "  <property name=\"geometry\">\n"
             "   <rect>\n"
             "    <x>0</x>\n"
             "    <y>0</y>\n"
             "    <width>150</width>\n"
             "    <height>150</height>\n"
             "   </rect>\n"
             "  </property>\n"
             "  <property name=\"toolTip\" >\n"
             "   <string>VTK OpenGL Widget</string>\n"
             "  </property>\n"
             "  <property name=\"whatsThis\" >\n"
             "   <string>VTK OpenGL Widget</string>\n"
             "  </property>\n"
             " </widget>\n"
             "</ui>\n";
    }
    
    QString QVTKOpenGLWidgePlugin::includeFile() const
    {
      return "QVTKOpenGLWidget.h";
    }
    

Log in to reply