title: QListView alignment and text wrapping in IconMode
body: <p>I am using <code>QListView</code> to show a list of files. When I am using its IconMode and file names are too long, I want it to split text in several lines. PySide <a href="https://srinikom.github.io/pyside-docs/PySide/QtGui/QListView.html#PySide.QtGui.PySide.QtGui.QListView.setWordWrap" rel="nofollow noreferrer">documentation</a> tells that <code>setWordWrap</code> function would work in other way:</p>
  
  <blockquote>
    <p>even if wrapping is enabled, the cell will not be expanded to make room for the text</p>
  </blockquote>
  
  <p>But that's what I need: break the text and expand item verically.</p>
  
  <p>So, can I use <code>QListView</code> to align files in a way it is often done in a file manager? For example, <a href="http://docs.xfce.org/xfce/thunar/start" rel="nofollow noreferrer">Thunar</a>:</p>
  
  <p><a href="https://i.stack.imgur.com/O0FFF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O0FFF.png" alt="Text is centered and broken into several lines in Thunar"></a></p>
  
  <p>This is my current code:</p>
  
  <pre><code>import sys
  from random import randint
  
  from PySide import QtGui
  from PySide import QtCore
  
  app = QtGui.QApplication(sys.argv)
  
  def gen_random_qicon():
      pixmap = QtGui.QPixmap(64, 64)
      pixmap.fill(
          QtGui.QColor(
              randint(0,255), randint(0,255), randint(0,255), 255
          )
      )
      icon = QtGui.QIcon()
      icon.addPixmap(pixmap)
      return(icon)
  
  class Test_model(QtCore.QAbstractListModel):
      def __init__(self, parent=None):
          super(Test_model, self).__init__(parent)
          self.__items = []
  
      def appendItem(self, item):
          index = len(self.__items)
  
          self.beginInsertRows(QtCore.QModelIndex(), index, index)
          self.__items.append(item)
          self.endInsertRows()
  
      def rowCount(self, parent):
          return len(self.__items)
  
      def data(self, index, role):
          image = self.__items[index.row()]
          if role == QtCore.Qt.DisplayRole:
              return image['name']
          if role == QtCore.Qt.DecorationRole:
              return gen_random_qicon()
          return None
  
  test_names = ["AB", "UO0E5", "WTRE76", "OSBTTEJ", "M4T2GW4Y55", "LI QM6WJKBC",
                "B4MO4 R6JD6"]
  test_model = Test_model()
  for tn in test_names:
      test_model.appendItem({"name": tn})
  
  lv = QtGui.QListView()
  lv.setFlow(QtGui.QListView.LeftToRight)
  lv.setResizeMode(QtGui.QListView.Adjust)
  lv.setViewMode(QtGui.QListView.IconMode)
  
  # Grid
  lv.setGridSize(QtCore.QSize(64, 64))
  lv.setTextElideMode(QtCore.Qt.ElideNone)
  
  lv.setModel(test_model)
  
  lv.resize(250, 200)
  lv.show()
  
  sys.exit(app.exec_())
  </code></pre>
  
  <p>When I use <code>setGridSize</code> function and set textElideMode as <code>ElideNone</code>, I have this result:</p>
  
  <p><a href="https://i.stack.imgur.com/KsbB2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KsbB2.png" alt="QListView with setGridSize and textElideMode as ElideNone"></a></p>
  
  <p>Otherwise, I see complete names, but I won't have the alignment.</p>
  
  <p><a href="https://i.stack.imgur.com/8SmVJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8SmVJ.png" alt="QListView without setGridSize"></a></p>