qtqquickwidget

QQuickWidget cannot promote


We've got trouble on promoting widgets. When we try to promote QQuickWidget to our class, we can't see QQuickWidget as base class despite other base classes. However sometimes it appears unless doing nothing special. Do you think this is a bug or is there anything to do to solve this problem ?

screenshot from Qt Creator


Solution

  • First of all: do you actually need the Designer to know about the widget being of the QQuickWidget type? You likely don't, so simply promote it directly from QWidget. They are all widgets, after all! The only difference a base class makes it that it exposes the derived-class-specific properties for editing using the Designer Ui - that's literally all. If you specifically need to adjust some properties of a QQuickWidget using the Designer interface, then you can just manually substitute the name inside the .ui file - it's just an XML file, easy to edit and understand.

    Specifically:

    sed -e 's/QWidget/QQuickWidget/g' < mypromoted.ui > myfinal.ui
    

    That's all it should take, and you can always verify the results in a text editor.