I work on a wood fire simulator project in university that uses QGIS. I have to draw various symbols on the map.

As I'm not able to design it with qgis functions so I made it with in a stand alone python program using PYQT5 like that:

enter image description here

Can I use my PYQT drawing functions in QGIS?


Actually, I'm working in a similar area and would recommend you to create styles of lines in Qgis, save them as qml files and use those files to render features in your PyQgis app. Handling styles in Qgis

As you can see from the picture my style of line is very similar to yours. In your standalone application, you can assign qml as follows


And if you wish your way you should look into qml format and create it from your application in order to use it in Qgis.

Access to Qgis style generator. I mean Qgis 3.2.3 Bonn 1. After you opened Qgis, follow items of menus: Layer-> Add Layer -> Add Vector Layer Open layer

  1. Supposing you opened layer Test_line and drew a polyline in it. Polyline

  2. Click right button mouse and choose Properties in the drop-down menu Drop-down menu

  3. Layer Properties dialog will appear where you should select the Symbology tab on the left side of the dialog Layer Properties

  4. Using the dialog you change color and width of the line (black and 0.26 in my case)

  5. Add symbol layer with the help of a plus button Add symbol layer
  6. Change Symbol layer type to Marker line Marker line
  7. Change Simple Marker to a triangle and its color to black Simple marker
  8. Select Simple line and change its offset to 1.0 and you'll get the desired style The style
  9. And on the map Map
  • Thanks for your answer! The problem is that I have to make a stand alone program using QGIS as a package and not a script I add to QGIS.
    – Skaldr
    Dec 20 '18 at 9:52
  • Actually, I meant exactly the same. I talked about how to use Qgis style generator in a pyqgis standalone application.
    – Vadym
    Dec 20 '18 at 10:02
  • Sorry I misread sometimes (English isn't my mother tongue). So How do I access the Qgis style generator? I tried but I can't find it.
    – Skaldr
    Jan 9 '19 at 13:33
  • Look at the answer again, I've tried to explain how to get the style you showed in your question.
    – Vadym
    Jan 9 '19 at 16:42
  • Thanks, it help me a lot! I still have a question: which kind of layer am I supposed to use for this?
    – Skaldr
    Jan 16 '19 at 10:26

In answer to your original question: "Can I use my PYQT drawing functions in QGIS" - the answer is yes!

You'd need to subclass the QgsLineSymbolLayer class, adding your custom drawing code inside the renderPolyline method. There's a good guide for how to do this at https://hub.packtpub.com/how-vector-features-are-displayed/ . Unfortunately it's for QGIS 2.18, so you'd need to adopt the API a little for use in QGIS 3 (mostly removal of the "V2" suffixes on the class names).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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