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 Updated to NodeBB v4.3 + New Features

Using QDesignerContainerExtension with custom widget page

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.5k Views 2 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.
  • T Offline
    T Offline
    tripleM
    wrote on 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
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on 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

      redtideR 1 Reply Last reply
      0
      • T Offline
        T Offline
        tripleM
        wrote on 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 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
          • JeroentjehomeJ Jeroentjehome

            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

            redtideR Offline
            redtideR Offline
            redtide
            wrote on 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
            • redtideR Offline
              redtideR Offline
              redtide
              wrote on 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