title: Unable to dynamically change KDE Plasma 5 Widget Expandable FullRepresentation Component size outside of Component.onCompleted
body: <p>I'm coding a widget that can be expanded to its FullRepresentation by being clicked on:</p>
  
  <pre><code>                onClicked: {
                      plasmoid.expanded = !plasmoid.expanded 
                  }
  </code></pre>
  
  <p>I have a function that updates its contents and puts them into a Gridview. The update function is first called from Component.onCompleted, but then I call it every time the user updates the data. The problem is the data I feed into the expandable FullRepresentation can contain a varying number of elements that I put into the gridview and calculate its AND the FullRepresentation's sizes based on this number.</p>
  
  <p>However, I find I'm only able to specify the Representation's size from the Component.onCompleted block. When I call the update function outside it, it doesn't change the size, no matter whether the size is defined in the item properties like so:</p>
  
  <pre><code>Item 
  {
      id: fullRepresentation
      width: no_items &gt; 2 ? 465 : no_items * 155
      height: Math.ceil(no_items / 3)* 155    
      property int no_items
  </code></pre>
  
  <p>...and I only try to change the no_items property from the UpdateFunction, or just try to run the two equations from it.</p>
  
  <p>Is there any way around this? I've also tried the implicitHeight and implicitWidth properties. I really would like to be able to dynamically adjust the size of the main expandable representation, it feels bad to have to hardcode it and then have a lot of unfilled space.</p>
  
  <p>EDIT:
  Here is the requested example:</p>
  
  <p><em>Root.qml</em></p>
  
  <pre><code>import org.kde.plasma.plasmoid 2.0
  import QtQuick 2.2
  
  Item
  {
      id: root
      width: 185; height: 185
      Plasmoid.compactRepresentation: Compact {}
      Plasmoid.fullRepresentation: Full {}
      Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
      signal addItems() 
  }
  </code></pre>
  
  <p><em>Compact.qml</em></p>
  
  <pre><code>import QtQuick 2.2
  
  Item
  {
      Rectangle
      {      
          width: root.width; height: root.height
          MouseArea
          {
              anchors.fill: parent
              acceptedButtons: Qt.LeftButton | Qt.RightButton
              onClicked: if (mouse.button == Qt.RightButton) root.addItems()
                         else plasmoid.expanded = !plasmoid.expanded
          }
      }
  }
  </code></pre>
  
  <p><em>Full.qml</em></p>
  
  <pre><code>import QtQuick 2.2
  
  Item 
  {
      width: no_items &gt; 2 ? 465 : no_items * 155
      height: Math.ceil(no_items / 3)* 155    
      property int no_items : 0
      function redrawGridView()  
      {        
          readingListModel.clear()       
          var i
          for (i = 0; i &lt; no_items; i++) readingListModel.append({})                
      }     
      function addItems()
      {
          no_items = 6
          width = no_items &gt; 2 ? 465 : no_items * 155
          height = Math.ceil(no_items / 3)* 155    
          redrawGridView()
      }
  
      ListModel 
      {
          id: readingListModel
      }
  
      GridView 
      { 
          id: readingGridView
          width: count &gt; 2 ? 465 : count * 155
          height: Math.ceil(count/3) * 155
          cellWidth: 155; cellHeight: 155
          model: readingListModel
          delegate: Rectangle
          {                  
              width: 150; height: 150;
          }
      }
  
     Component.onCompleted:
      {            
          root.addItems.connect(addItems)    
          no_items = 3  
          redrawGridView()
      }
  }
  </code></pre>