I have an external windows standalone python application that uses pyqgis. When I display a QgsRendererPropertiesDialog, python crashes when the user clicks on any color button (screenshot: http://psr.me/1903oq2). The problem 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. Apparently this option has been removed. I also noticed that QGis uses a color dialog different from the one that appears in my application. How can I configure my application (from pyqgis) to use the same dialog? I wrote a very small PyQt5 application (below, at the end) that reproduces the problem. Any thoughts on how to fix this? 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()
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer