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. Using QDesignerContainerExtension with custom widget page
Forum Update on Monday, May 27th 2025

Using QDesignerContainerExtension with custom widget page

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.4k Views
  • 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.
  • T Offline
    T Offline
    tripleM
    wrote on 24 Sept 2014, 07:23 last edited by
    #1

    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!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jeroentjehome
      wrote on 24 Sept 2014, 12:26 last edited by
      #2

      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

      Greetz, Jeroen

      R 1 Reply Last reply 23 Jan 2024, 09:30
      0
      • T Offline
        T Offline
        tripleM
        wrote on 24 Sept 2014, 12:41 last edited by
        #3

        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)

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KleinBottle
          wrote on 24 May 2015, 14:59 last edited by KleinBottle
          #4

          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.

          1 Reply Last reply
          0
          • J Jeroentjehome
            24 Sept 2014, 12:26

            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

            R Offline
            R Offline
            redtide
            wrote on 23 Jan 2024, 09:30 last edited by
            #5

            @Jeroentjehome 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

            This is not helpful for the custom class name and both qobject_cast and dynamic_cast, as @tripleM said, don't work, that will make crash the designer. Only a static_cast works.
            You can only assign the object name to replace the page_N to some pane_N, but I see no way to tell the designer to use a different class via domXml() for all pages added later.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              redtide
              wrote on 13 Feb 2024, 12:46 last edited by
              #6

              It took about 10 years to discover that it's not possible. :-)

              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