Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Designer QML DummyContextObject
Forum Updated to NodeBB v4.3 + New Features

Qt Designer QML DummyContextObject

Scheduled Pinned Locked Moved Qt Creator and other tools
11 Posts 2 Posters 4.1k Views 1 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
    ThomasHartmann
    wrote on last edited by
    #2

    bq. I can’t find the module QmlDesigner 1.0. Anyone know how to do this?

    The blog post describes it correctly. The "QmlDesigner" import is just for the designer and not known to QML/the code model.

    Note that you can also use the width and height field in the form editor to override width and height of the root item without actually changing the .qml file.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      simgunz
      wrote on last edited by
      #3

      Ok I understand. The width and height in the designer do the job of DummyContext.

      One more question.

      I have the following situation:

      @BasicComponent.qml@

      @Item{
      property Component pageComponent
      /CODE/
      Loader{
      sourceComponent: pageComponent
      }
      }@

      @DerivedComponent.qml@

      @BasicComponent{
      pageComponent: Item{
      /CODE/
      }
      }@

      when I open the DerivedComponent in Qt Designer I can see the DerivedComponent components but I can't edit them, in fact in the navigator the only element displayed is DerivedComponent without any child. Is there a way to edit the DerivedComponent graphically with QtDesigner in this situation? Which are the alternatives to do this?

      Thanks

      1 Reply Last reply
      0
      • T Offline
        T Offline
        ThomasHartmann
        wrote on last edited by
        #4

        Next to the file name on top of the designer is a combo-box.
        There you can select all components defined in the current file and edit them
        as if they were defined in a separate file.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          simgunz
          wrote on last edited by
          #5

          Thanks. I haven't noticed it.

          Now the situation is this:

          1. when "master" is selected I can see all the components but I can't edit them
          2. when in the combo box I select the item loaded by the Loader I can see the hierarchy of the components in the navigator by I can't see any of them on the canvas. Is it because they are custom components created by me? How can I make Qt Designer aware of these new components?
          1 Reply Last reply
          0
          • T Offline
            T Offline
            ThomasHartmann
            wrote on last edited by
            #6

            If you components worked in the master document they should work here.
            Maybe the size is (0,0) or visibility is false?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              simgunz
              wrote on last edited by
              #7

              They are visible and they are inside a layout. May the layout cause the problem?

              The size of ImageButton is not defined in the source of ImageButton but it should be set by the layout, in fact in the master the two ImageButton are displayed correctly.

              @BasicPage {
              id: gameModePage

              pageComponent: Item{
              
                  RowLayout {
                      id: rowLayout
                      anchors.fill: parent
              
                      ImageButton {
                          id: buttonModeFood
                          buttonId: 1
                          buttonPath: "../images/food.jpg"
                          Layout.preferredWidth: gameModePage.width/3
                          Layout.preferredHeight: gameModePage.height/3
                          Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                          onBtnClicked: foodGamePage()
                      }
              
                      ImageButton {
                          id: buttonModeLight
                          buttonId: 1
                          buttonPath: "../images/laser.jpg"
                          Layout.preferredWidth: gameModePage.width/3
                          Layout.preferredHeight: gameModePage.height/3
                          Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                          onBtnClicked: lightGamePage()
                      }
                  }
              }
              

              }@

              1 Reply Last reply
              0
              • S Offline
                S Offline
                simgunz
                wrote on last edited by
                #8

                Actually the size of ImageButton is 0,0, if I set it manually I can see the ImageButton. But I expect the layout set the size.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  ThomasHartmann
                  wrote on last edited by
                  #9

                  This the reason:

                  RowLayout {
                  id: rowLayout
                  anchors.fill: parent <-you anchor to the parent
                  ...

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    simgunz
                    wrote on last edited by
                    #10

                    So, how should I anchor it?

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      ThomasHartmann
                      wrote on last edited by
                      #11

                      If you leave out the anchors.fill: parent , then the layout will resize itself to its content.

                      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