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

QtCreator - show python or c++ based qml components in visual editor



  • Is that possible to show python-based qml components in visual editor?
    Lets assume I have following component:

    class QmlQImage(QQuickPaintedItem):
        def __init__(self, parent=None):
            super().__init__(parent)
            self.image_val = QImage()
    
        def get_image(self):
            return self.image_val
    
        def set_image(self, val):
            self.image_val = val
    
        image = Property(int, get_image, set_image)
    
        def paint(self, painter: PySide2.QtGui.QPainter):
            painter.drawImage(QRect(0, 0, painter.device().height(), painter.device().width()), self.image_val)
    
    qmlRegisterType(QmlQImage, 'QmlExt', 1, 0, 'QmlQImage')
    

    and qml file

    import QtQuick 2.0
    import QmlExt 1.0
    
    QmlQImage {
        width: 256; height: 256
    }
    

    When trying to edit that qml file I am observing following error:
    f902cc0c-8358-408c-9872-00b21a4ed94f-image.png

    Also, is that possible to display c++ based components in QML editor? If yes, can someone provide link how to achieve that?

    Thanks in advance.


Log in to reply