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.
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
Supposing you opened layer Test_line and drew a polyline in it.
Click right button mouse and choose Properties in the drop-down menu
Layer Properties dialog will appear where you should select the Symbology tab on the left side of the dialog
Using the dialog you change color and width of the line (black and 0.26 in my case)
- Add symbol layer with the help of a plus button
- Change Symbol layer type to Marker line
- Change Simple Marker to a triangle and its color to black
- Select Simple line and change its offset to 1.0 and you'll get the desired style
- And on the map