Plugin with type dock doesn't fill available width

• Feb 13, 2021 - 10:51

Hi,

my plugin looks like in the screenshot: it's elements don't fill the width.

When I compare it to the demo plugin random2 I can't see the difference.

My plugin code is:

...
    pluginType: "dock"
    dockArea:   "left"

    width:  200
    height: 700
    Layout.fillWidth: true

    GridLayout {
        anchors.fill: parent
        columns: 1
        rowSpacing: 1

        Text {
            text: "Instrument (anzeigen)"
            horizontalAlignment: Text.AlignHCenter
            Layout.fillWidth: true
            MouseArea {
                anchors.fill: parent
            }
        }
        ComboBox {
            id: comboModel
            Layout.fillWidth: true
            textRole: "value"
...

It's pretty much the same as random2.qml from layout instructions as far as I see...

Any ideas?

Attachment Size
screenshot-2021-02-13-10-57-06.png 50.69 KB

Comments

It would be helpful if you could attach a full plugin code, at least some minimal example on which the issue is reproducible. From what I see I would try the following possible solutions:
- Replacing the top-level width and height properties with implicitWidth and implicitHeight: implicit versions of these properties won't enforce fixed width or height so they may behave better in this regard, and they still ensure the correct initial dimensions of the plugin view.
- Removing the top-level Layout.fillWidth: true: I am not sure if it does anything useful at the plugin's top-level component but I don't see anything like this in the code of random2.qml.

In reply to by dmitrio95

Thank you dimitrio95. At the end, it was just a missing anchors.fill: parent in GridLayout. A few problems played together and made it hard to spot the problem:

  1. I tested mostly in the "Plug-In Editor". It still doesn't work there.
  2. I didn't always press "Reload plugins" in the plugin manager before starting the plugin.
  3. I have two different versions of the plugin (one for ES5 capable Linux and one for other systems) and I might have forgot sometimes to compile the correct one...

The patch below fixed it.

diff --git a/plugins/musescore/nn2gs.qml.template b/plugins/musescore/nn2gs.qml.template
index c226717..420687f 100644
--- a/plugins/musescore/nn2gs.qml.template
+++ b/plugins/musescore/nn2gs.qml.template
@@ -48,9 +48,6 @@ MuseScore {

     implicitWidth:  200
     implicitHeight: 700
-    //width:  200
-    //height: 200
-    //Layout.fillWidth: true

     // Polyfills used by compiled functions:
     property var $jscomp: {}
@@ -240,7 +237,7 @@ MuseScore {
     }

     GridLayout {
-        //anchors.fill: parent
+        anchors.fill: parent
         Layout.fillWidth: true
         columns: 1
         rowSpacing: 1

Do you still have an unanswered question? Please log in first to post your question.