It's quite easy to modify the default style that QGIS applies when selecting attributes in the GUI by following the steps in this question: QGIS: How to modify the appearence of selected attributes
However, when working with a stand-alone script that opens the same project, selects a feature and exports the contents of the bounding box to a png, the selection style is still the same default yellow.
For rendering and saving, I'm following the steps described in the QGIS Cookbook. The only addition is feature selection and setting extents to feature bounding box.
I probably have to set the style explicitly in a stand-alone script. How to accomplish that?
EDIT: MINIMAL REPRODUCE
Step 1: modify selected feature style in project
Step 2: load project and try to render layer with the following code
project = QgsProject.instance() project.read('/where/my/project/at') vlayer = project.mapLayersByName('MY_LAYER') vlayer.selectByIds([my_id]) settings = QgsMapSettings() settings.setLayers([vlayer]) settings.setBackgroundColor(QColor(255, 255, 255)) settings.setOutputSize(QSize(800, 600)) settings.setExtent(vlayer.extent()) render = QgsMapRendererParallelJob(settings) image_location = os.path.join(QgsProject.instance().homePath(), "render.png") def finished(): img = render.renderedImage() # save the image; e.g. img.save("/Users/myuser/render.png","png") img.save(image_location, "png") render.finished.connect(finished) # Start the rendering render.start() # The following loop is not normally required, we # are using it here because this is a standalone example. from qgis.PyQt.QtCore import QEventLoop loop = QEventLoop() render.finished.connect(loop.quit) loop.exec_()
Step 3: feature selected but selection color still standard QGIS yellow.