Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Designer Plugin for QVTKOpenGLWidget?
Qt 6.11 is out! See what's new in the release blog

Designer Plugin for QVTKOpenGLWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 750 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • apalomerA Offline
    apalomerA Offline
    apalomer
    wrote on last edited by apalomer
    #1

    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";
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved