Hello,

I used Michal Fapsos implementation of this dialog and it worked with Qt 5.6.1 .

Now I am using Qt 5.9.2 and it does not work anymore, giving the following error:
Qt Code:
  1. Traceback (most recent call last):
  2. File "main.py", line 74, in mouseDoubleClickEvent
  3. self.openFileDialog()
  4. File "main.py", line 123, in openFileDialog
  5. openDialog = QFileDialogPreview(self, 'Open file', './', self.getDialogFilter())
  6. File "QFileDialogPreview.py", line 22, in __init__
  7. self.layout().addLayout(box, 1, 3, 1, 1)
  8. TypeError: addLayout(self, QLayout, stretch: int = 0): too many arguments
To copy to clipboard, switch view to plain text mode 
Here is the translated class. I am using Python 3.5.2:
Qt Code:
  1. from PyQt5.QtWidgets import QFileDialog, QLabel, QVBoxLayout
  2. from PyQt5.QtGui import QPixmap
  3. from PyQt5.QtCore import Qt
  4.  
  5. class QFileDialogPreview(QFileDialog):
  6. def __init__(self, parent, caption, direcotry, filter):
  7. super().__init__(parent, caption, direcotry, filter)
  8.  
  9. self.setObjectName("FileDialogPreview")
  10. box = QVBoxLayout(self)
  11.  
  12. self.setFixedSize(self.width() + 250, self.height())
  13.  
  14. self.mpPreview = QLabel("Preview", self)
  15. self.mpPreview.setFixedSize(250, 250)
  16. self.mpPreview.setAlignment(Qt.AlignCenter)
  17. self.mpPreview.setObjectName("labelPreview")
  18. box.addWidget(self.mpPreview)
  19.  
  20. box.addStretch()
  21.  
  22. self.layout().addLayout(box, 1, 3, 1, 1)
  23.  
  24. self.currentChanged.connect(self.onChange)
  25. self.fileSelected.connect(self.onFileSelected)
  26. self.filesSelected.connect(self.onFilesSelected)
  27.  
  28. self._fileSelected = None
  29. self._filesSelected = None
  30.  
  31. def onChange(self, path):
  32. pixmap = QPixmap(path)
  33.  
  34. if(pixmap.isNull()):
  35. self.mpPreview.setText("Preview")
  36. else:
  37. self.mpPreview.setPixmap(pixmap.scaled(self.mpPreview.width(), self.mpPreview.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
  38.  
  39. def onFileSelected(self, file):
  40. self._fileSelected = file
  41.  
  42. def onFilesSelected(self, files):
  43. self._filesSelected = files
  44.  
  45. def getFileSelected(self):
  46. return self._fileSelected
  47.  
  48. def getFilesSelected(self):
  49. return self._filesSelected
To copy to clipboard, switch view to plain text mode 

Has there been a change in the layout of QFileDialog, which should be a QGridLayout, but now is a QVBoxLayout, or is the problem somewhere else?

I am confident in the code working before, since it ran on my linux machine (Qt 5.6.1), but running it on my windows using (Qt 5.9.3) failed with the above error as well.