In my QGIS plugin I select dynamically features from a Vector layer. And currently I create a new layer (shapefile) from selection on combining all feature into a new feature:
theField = QgsField
self.theString = (os.path.expanduser("~")+'\.qgis\\statsRectangle.shp')
feat = QgsFeature()
shapeLayer2 = QgsVectorLayer(self.theString, "Upstream Area Of Interest", 'ogr')
geomtotSubwatershed = QgsGeometry.fromWkt('GEOMETRYCOLLECTION EMPTY')
nodLayer.setSelectedFeatures(selectFeatureIDlist)
UpstreamGeometry = QgsGeometry.fromWkt('GEOMETRYCOLLECTION EMPTY')
for elem in nodLayer.selectedFeatures():
UpstreamGeometry = UpstreamGeometry.combine(elem.geometry())
feat.setGeometry(UpstreamGeometry)
QgsMapLayerRegistry.instance().addMapLayer(shapeLayer2)
but combining selected feature take a long time and froze QGIS UI.