I need to draw a multicoloured line with QPen
that may consist of up to three colours within a dashed pattern.
Different colours should be on one line.
Any suggestions on how I can achieve it?
Thank you.
I need to draw a multicoloured line with QPen
that may consist of up to three colours within a dashed pattern.
Different colours should be on one line.
Any suggestions on how I can achieve it?
Thank you.
Copyright © 2021 Jogjafile Inc.
Developing the idea of @goug, you can do something like:
Now, a more generic solution for
n
colors (I know it has too many parameters, it's just an idea). The trick is done creating a single dash-pattern, and moving it usingQPen::setDashOffset
for each color:So they can be called:
The full working example is available at GitHub