| 129 | return size |
| 130 | |
| 131 | def doLayout(self, rect, testOnly): |
| 132 | x = rect.x() |
| 133 | y = rect.y() |
| 134 | lineHeight = 0 |
| 135 | |
| 136 | for item in self.itemList: |
| 137 | wid = item.widget() |
| 138 | spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, |
| 139 | QSizePolicy.PushButton, Qt.Horizontal) |
| 140 | spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, |
| 141 | QSizePolicy.PushButton, Qt.Vertical) |
| 142 | nextX = x + item.sizeHint().width() + spaceX |
| 143 | if nextX - spaceX > rect.right() and lineHeight > 0: |
| 144 | x = rect.x() |
| 145 | y = y + lineHeight + spaceY |
| 146 | nextX = x + item.sizeHint().width() + spaceX |
| 147 | lineHeight = 0 |
| 148 | |
| 149 | if not testOnly: |
| 150 | item.setGeometry(QRect(QPoint(x, y), item.sizeHint())) |
| 151 | |
| 152 | x = nextX |
| 153 | lineHeight = max(lineHeight, item.sizeHint().height()) |
| 154 | |
| 155 | return y + lineHeight - rect.y() |
| 156 | |
| 157 | |
| 158 | if __name__ == '__main__': |