relates to QGIS 2.14.6LTR on Win10, PyQt Version 4.10.2

When trying to makeGraph() on QgsLineVectorLayerDirector as described in the "QGIS Network analysis library" documentation (http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/network_analysis.html) like

director = QgsLineVectorLayerDirector(vl, -1, '', '', '', 3)
psource = f_source.geometry()
ptarget = f_target.geometry()
#each assumed to be of type QgsPoint 
#director has added a QgsDistanceArcProperter
#builder is a QgsGraphBuiler
director.makeGraph(builder, [psource, ptarget])

I get an error message QgsLineVectorLayerDirector.makeGraph(QgsGraphBuilderInterface, list-of-QgsPoint): argument 2 has unexpected type 'list' See log for more details

Isn't the list internaly converted to QVector which is expected by makeGraph() https://qgis.org/api/classQgsLineVectorLayerDirector.html#af14ff34e31a2860edd156090c0f746ef

What should I pass to makeGraph() instead of my list?


tp = QVector()
tiedPoints = director.makeGraph(builder, tp)

but name 'QVector' is not defined See log for more details. Isn't this imported with from PyQt4.QtCore import * ?

ADD: Obviously not: enter image description here

Refer to also: https://stackoverflow.com/questions/39746241/pyqt4-convert-list-to-qvector

2 Answers 2


@ekhumoro gives following answer to the question https://stackoverflow.com/questions/39746241/pyqt4-convert-list-to-qvector:

"PyQt has never wrapped the QVector class, and it's unlikely that there will ever be a reason for doing so.

The QgsLineVectorLayerDirector.makeGraph method is expecting a list of QgsPoint instances. So presumably either (1) the list you're passing in doesn't contain objects that are all of the right type, or (2) the Qgs library you're using is broken."

Related to my above question, the solution is that

psource = f_source.geometry()
ptarget = f_target.geometry()

return QgsGeometry and not QgsPoint as desired, so correct ist would be

psource = f_source.geometry().asPoint()
ptarget = f_target.geometry().asPoint()

Wrong type of argument:

void    makeGraph (QgsGraphBuilderInterface *builder, const QVector< QgsPoint > &additionalPoints, QVector< QgsPoint > &tiedPoints)

Second argument should be QVector type, not a list.

And if you cant import:

from PyQt4.QtCore import QVector

that means your PyQt is 4.6 or below. You should update it to 4.7+.

  • I'll check this out, but how to update a) Case of installed qgis from exe Installer or b) Case of installed from osgeo4w Installer? Sep 28, 2016 at 13:56
  • I have no idea how it works on Windows.
    – dmh126
    Sep 28, 2016 at 14:03
  • QtCore.PYQT_VERSION_STR gives me 4.10.2 wich I think is 4.7+. Sep 28, 2016 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.