Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Multi colored PolyLines?
Forum Update on Monday, May 27th 2025

[SOLVED] Multi colored PolyLines?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EukeSnud
    wrote on last edited by
    #1

    Is there a way to draw PolyLines with a QPainter, so that each element of the polyline may have a different color or do I have to realize this with seperate lines?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      You can use a QLinearGradient and pass it to QPainter using QBrush and setBrush()!

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        If loladiro's suggestion doesn't do what you need, then you'll need to draw each line segment on your own by iterating over the line segments and adjusting the pen accordingly for each one.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          EukeSnud
          wrote on last edited by
          #4

          [quote author="mlong" date="1311786901"]If loladiro's suggestion doesn't do what you need, then you'll need to draw each line segment on your own by iterating over the line segments and adjusting the pen accordingly for each one.
          [/quote]

          Already did it this way (also for another couple or reasons!)

          Thanks

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved