Using QDesignerContainerExtension with custom widget page



  • Hi.

    I have made a custom widget that extends from QDesignerContainerExtension pretty similar to the one in the "container extension example":http://qt-project.org/doc/qt-5/qtdesigner-containerextension-example.html.
    However, I would like my new pages to be a custom widget that I have designed (let's call it CustomPage) and not QWidget as it is by default.

    The way I see it the addWidget/insertWidget of the container extension
    @void addWidget(QWidget *widget)
    void instertWidget(int index, QWidget *widget)@

    can't be changed to what I need:

    @void addWidget(CustomPage *widget)
    void insertWidget(int index, CustomPage *widget)@

    because these functions are called from Qt's source code.

    I'd like to think there's a work around this problem, anyone have any ideas?
    Thanks!



  • Hi,
    When your custom widget derives from the QWidget base class it should remain so in the function call.
    In the addWidget do a dynamic cast to the CustomPage if you overwritten that function



  • Hi,

    Doing a dynamic_cast just results in a null pointer since the QWidget is created within Qt Designer and then used in the call of addWidget in the ContainerExtension class (which is sublassed from: "QDesignerContainerExtension":http://doc-snapshot.qt-project.org/qt5-5.4/qdesignercontainerextension.html)



  • Hi,

    I'm trying to do this too, replacing the QWidget supplied by designer with my own (as suggested here: http://forum.qt.io/topic/12497/qtdesigner-container-plugin-with-custom-page-class/3) just results in designer throwing the error (substituting your names for classes):

    "The container extension of the widget 'CustomContainer' (CCustomContainer) returned a widget not managed by Designer 'page_1' (CustomPage) when queried for page #0. Container pages should only be added by specifying them in XML returned by the domXml() method of the custom widget."

    In my case the page class (CustomClass) is also registered as a plugin (and works by itself) but that doesn't seem to help. I also can't find any reference in the domXML schema to an XML mechanism to do anything but specify the <addpagemethod> so I don't know what the error message is telling me.

    Did you ever find a solution?

    Thanks for any help anyone can give.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.