title: My QGridLayout in PyQt doesn't show all elements, or in the right places
body: <p>When I look at my MainWindow in Qt Designer, I see this <a href="https://i.stack.imgur.com/JuQxr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JuQxr.png" alt="MainWindow"></a></p>
  
  <p>However, when I compile ui file into python code, take the match object (a QGroupBox with "Champion" as the title, inside match history), and port it over so that I can build many of these things and add them all to the scroll area (Match History) and run it I get this<a href="https://i.stack.imgur.com/n9avv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n9avv.png" alt="BAD MainWindow"></a></p>
  
  <p>The group box ends shortly after the bottom of the window, so it doesn't go on forever, and I have confirmed in my code that the width and height of the group box is set correctly. I've also confirmed that the match object does indeed have 10 slots and has the items in it after being built, the problem is just that it doesn't look right at runtime. What's going wrong?</p>
  
  <p>Here is the buildMatch method:</p>
  
  <pre><code>def buildMatch(self, summonerId, matchIndex, matchId, matchWidth, matchHeight):
      # This method takes the matchIndex and matchId as an input, builds a match object, and returns it. As a part of 
      # building each match object, this method calls calculateMatchStatistics() and calculateAverages. It might be 
      # prudent later to only call self.calculateAverages() once, rather than every time, but I'm not sure.
      # Globals: none
  
      # Check whether we have match data for the matchID in question. If we do, 
      # continue. If not, call getMatchDetails for the match and store that data in matchHistoryDetails.
      # Keys of the matchHistoryDetails dictionary will be unicode strings. Convert the matchId to unicode 
      # before using as a key or lookup element.
      matchId = unicode(matchId)
      knownMatchIds = self.matchHistoryDetails.keys()
      if matchId not in knownMatchIds:
          self.matchHistoryDetails[matchId] = self.getMatchDetails(summonerId, matchId)
  
      # Load champion name from getChampionName() and lane from matchHistoryList
      championId = self.matchHistoryList["matches"][matchIndex]["champion"]
      championName = self.getChampionName(championId)
  
      match = QGroupBox(championName)
      match.setFixedHeight(matchWidth)
      match.setFixedWidth(matchHeight)
  
      matchWidget = QWidget(match)
      matchWidget.setGeometry(QRect(10, 20, matchWidth, matchHeight))
      matchLayout = QGridLayout(matchWidget)
  
      statisticsBoxToMatchWidthRatio = .165
      statisticsBoxToMatchHeightRatio = .3895
      statisticsBoxWidth = int(matchWidth * statisticsBoxToMatchWidthRatio)
      statisticsBoxHeight = int(matchHeight * statisticsBoxToMatchHeightRatio)
  
      scoreBox = QGroupBox(matchWidget)
      scoreBox.setAlignment(Qt.AlignCenter)
      scoreBox.setTitle("score")
      scoreBox.setStyleSheet('QGroupBox {font: 8pt "Calibri"}')
      scoreBox.setToolTip("Score, in the format of kills-deaths-assists")
      scoreValue = QLabel(scoreBox)
      scoreValue.setGeometry(QRect(10, 29, statisticsBoxWidth, statisticsBoxHeight))
      scoreValue.setAlignment(Qt.AlignCenter)
      scoreValue.setStyleSheet('font: 9pt "Calibri";')
  
      kdaBox = QGroupBox(matchWidget)
      kdaBox.setAlignment(Qt.AlignCenter)
      kdaBox.setTitle("KDA")
      kdaBox.setStyleSheet('QGroupBox {font: 8pt "Calibri"}')
      kdaBox.setToolTip("Calculated by (kills+deaths)/assists")
      kdaValue = QLabel(kdaBox)
      kdaValue.setGeometry(QRect(10, 29, statisticsBoxWidth, statisticsBoxHeight))
      kdaValue.setAlignment(Qt.AlignCenter)
  
      killParticipationPercentBox = QGroupBox(matchWidget)
      killParticipationPercentBox.setAlignment(Qt.AlignCenter)
      killParticipationPercentBox.setTitle("Kill part. %")
      killParticipationPercentBox.setStyleSheet('QGroupBox {font: 8pt "Calibri"}')
      killParticipationPercentBox.setToolTip("The percentage of your teams kills you contributed to")
      killParticipationPercentValue = QLabel(killParticipationPercentBox)
      killParticipationPercentValue.setGeometry(QRect(10, 29, statisticsBoxWidth, statisticsBoxHeight))
      killParticipationPercentValue.setAlignment(Qt.AlignCenter)
  
      goldPerMinBox = QGroupBox(matchWidget)
      goldPerMinBox.setAlignment(Qt.AlignCenter)
      goldPerMinBox.setTitle("gold/min")
      goldPerMinBox.setStyleSheet('QGroupBox {font: 8pt "Calibri"}')
      goldPerMinBox.setToolTip("Gold earned per minute")
      goldPerMinValue = QLabel(goldPerMinBox)
      goldPerMinValue.setGeometry(QRect(11, 29, statisticsBoxWidth, statisticsBoxHeight))
      goldPerMinValue.setAlignment(Qt.AlignCenter)
  
      wardScoreBox = QGroupBox(matchWidget)
      wardScoreBox.setAlignment(Qt.AlignCenter)
      wardScoreBox.setTitle("ward score")
      wardScoreBox.setStyleSheet('QGroupBox {font: 8pt "Calibri"}')
      wardScoreBox.setToolTip("Calculated by wards placed + wards killed")
      wardScoreValue = QLabel(wardScoreBox)
      wardScoreValue.setGeometry(QRect(10, 30, statisticsBoxWidth, statisticsBoxHeight))
      wardScoreValue.setAlignment(Qt.AlignCenter)
  
      csPerMinBox = QGroupBox(matchWidget)
      csPerMinBox.setAlignment(Qt.AlignCenter)
      csPerMinBox.setTitle("cs/min")
      csPerMinBox.setStyleSheet('QGroupBox {font: 8pt "Calibri"}')
      csPerMinBox.setToolTip("Creeps killed per minute")
      csPerMinValue = QLabel(csPerMinBox)
      csPerMinValue.setGeometry(QRect(10, 29, statisticsBoxWidth, statisticsBoxHeight))
      csPerMinValue.setAlignment(Qt.AlignCenter)
  
      spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  
      laneLabel = QLabel(matchWidget)
      laneLabel.setAlignment(Qt.AlignCenter)
      laneLabel.setStyleSheet('font: 10pt "Calibri";')
      laneLabel.setToolTip("Lane")
  
      spacerItem3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
  
      resultLabel = QLabel(matchWidget)
      resultLabel.setAlignment(Qt.AlignCenter)
      resultLabel.setStyleSheet('font: 12pt "Calibri"')
      resultLabel.setToolTip("Match result")
  
      matchLayout.addItem(spacerItem2, 0, 1, 1, 1)
      matchLayout.addWidget(scoreBox, 0, 2, 1, 1)
      matchLayout.addWidget(killParticipationPercentBox, 0, 3, 1, 1)
      matchLayout.addWidget(wardScoreBox, 0, 4, 1, 1)
      matchLayout.addItem(spacerItem3, 0, 5, 1, 1)
      matchLayout.addWidget(resultLabel, 0, 6, 1, 1)
      matchLayout.addWidget(laneLabel, 1, 0, 1, 1)
      matchLayout.addWidget(kdaBox, 1, 2, 1, 1)
      matchLayout.addWidget(goldPerMinBox, 1, 3, 1, 1)
      matchLayout.addWidget(csPerMinBox, 1, 4, 1, 1)
  
      matchLayout.setColumnStretch(0, 10)
      matchLayout.setColumnStretch(1, 3)
      matchLayout.setColumnStretch(2, 11)
      matchLayout.setColumnStretch(3, 10)
      matchLayout.setColumnStretch(4, 10)
      matchLayout.setColumnStretch(5, 3)
      matchLayout.setColumnStretch(6, 10)
      matchLayout.setRowStretch(0, 10)
      matchLayout.setRowStretch(1, 10)
  
      ##################################################
  
      # Set values for each item
      matchWon = self.matchHistoryStatistics["matches"][matchId]["won"]
      if matchWon:
          result = "Win"
      else:
          result = "Loss"
      score = self.matchHistoryStatistics["matches"][matchId]["score"]
      kda = self.matchHistoryStatistics["matches"][matchId]["kda"]
      kdaAverage = self.matchHistoryStatistics["kdaAverage"]
      killParticipationPercent = self.matchHistoryStatistics["matches"][matchId]["killParticipationPercent"]
      killParticipationPercentAverage = self.matchHistoryStatistics["killParticipationPercentAverage"]
      wardScore = self.matchHistoryStatistics["matches"][matchId]["wardScore"]
      wardScoreAverage = self.matchHistoryStatistics["wardScoreAverage"]
      goldPerMin = self.matchHistoryStatistics["matches"][matchId]["goldPerMin"]
      goldPerMinAverage = self.matchHistoryStatistics["goldPerMinAverage"]
      csPerMin = self.matchHistoryStatistics["matches"][matchId]["csPerMin"]
      csPerMinAverage = self.matchHistoryStatistics["csPerMinAverage"]
      lane = self.matchHistoryList["matches"][matchIndex]["lane"].lower().capitalize()
      if lane == "Bottom":
          lane = "Bot"
  
      resultLabel.setText(result)
      scoreValue.setText(str(score))
      kdaValue.setText(str(kda))
      killParticipationPercentValue.setText(str(killParticipationPercent))
      wardScoreValue.setText(str(wardScore))
      goldPerMinValue.setText(str(goldPerMin))
      csPerMinValue.setText(str(csPerMin))
      laneLabel.setText(lane)
  
      if result == "Win":
          resultLabel.setStyleSheet('color: green; font: 12pt "Calibri";')
      else:
          resultLabel.setStyleSheet('color: red; font: 12pt "Calibri";')
      if kda &gt; kdaAverage:
          kdaValue.setStyleSheet('color: green; font: 9pt "Calibri";')
      else:
          kdaValue.setStyleSheet('color: red; font: 9pt "Calibri";')
      if killParticipationPercent &gt; killParticipationPercentAverage:
          killParticipationPercentValue.setStyleSheet('color: green; font: 9pt "Calibri";')
      else:
          killParticipationPercentValue.setStyleSheet('color: red; font: 9pt "Calibri";')
      if wardScore &gt; wardScoreAverage:
          wardScoreValue.setStyleSheet('color: green; font: 9pt "Calibri";')
      else:
          wardScoreValue.setStyleSheet('color: red; font: 9pt "Calibri";')
      if goldPerMin &gt; goldPerMinAverage:
          goldPerMinValue.setStyleSheet('color: green; font: 9pt "Calibri";')
      else:
          goldPerMinValue.setStyleSheet('color: red; font: 9pt "Calibri";')
      if csPerMin &gt; csPerMinAverage:
          csPerMinValue.setStyleSheet('color: green; font: 9pt "Calibri";')
      else:
          csPerMinValue.setStyleSheet('color: red; font: 9pt "Calibri";')
  
      return match
  </code></pre>