<div dir="ltr"><pre style="white-space:pre-wrap;color:rgb(0,0,0)">I have an external windows standalone python application that uses pyqgis.
When I display a QgsRendererPropertiesDialog, python crashes (sometimes) when the user clicks on any color button (screenshot: <a href="http://psr.me/1903oq2">http://psr.me/1903oq2</a>). The problem is intermitent and seems to be in displaying the color dialog. In previous QGis versions I could avoid this problem by using:
settings = QgsSettings()
settings.setValue('qgis/native_color_dialogs', True)
QGis then used another color dialog that did not crash my application.
However, since I updated to QGis 3.8.3 (OSGEO4W) this option no longer
works.
I wrote a very small PyQt5 application (below, at the end) that reproduces
the problem: the color button sometimes crashes the application.</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif">Any thoughts on how to fix this?</span><br></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)">Operating system: Windows 10 Home
Python version: 3.7.0 (OSGEO4W)
QGis version: 3.8.3 (OSGEO4W)
Thanks,
Marcelo Metello
from qgis.core import QgsVectorLayer, QgsStyle
from qgis.gui import QgsRendererPropertiesDialog
from PyQt5 import QtCore, QtWidgets
def editStyle():
layer = QgsVectorLayer('LineString?field=level:integer',
'contour_lines', 'memory')
dialog = QtWidgets.QDialog()
layout = QtWidgets.QVBoxLayout(dialog)
# Add symbology panel
symbPanel = QgsRendererPropertiesDialog(layer, QgsStyle.defaultStyle(),
True)
layout.addWidget(symbPanel)
# Add Ok Cancel button box
buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |
QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, dialog)
buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText('Ok')
buttonBox.button(QtWidgets.QDialogButtonBox.Cancel).setText('Cancel')
buttonBox.accepted.connect(dialog.accept)
buttonBox.rejected.connect(dialog.reject)
layout.addWidget(buttonBox)
dialog.setLayout(layout)
dialog.adjustSize()
if (dialog.exec_() == QtWidgets.QDialog.Accepted):
symbPanel.apply()
# Create simple application with only one button
app = QtWidgets.QApplication([])
window = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout()
editBtn = QtWidgets.QPushButton('Edit Style')
editBtn.clicked.connect(editStyle)
layout.addWidget(editBtn)
window.setLayout(layout)
window.show()
app.exec_()
app.exit()</pre></div>