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. QGraphicsItem draw perpendicular line as wide as pen

QGraphicsItem draw perpendicular line as wide as pen

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt4qgraphicsitemqlineqpen
1 Posts 1 Posters 1.4k Views 1 Watching
  • 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.
  • 6 Offline
    6 Offline
    6b656d70
    wrote on last edited by
    #1

    Hi,

    I am working in PyQt but am comfortable with any help written in C++.

    I have an application that contains a number of custom QGraphicsItems that are essentially a series of straight lines rendered as a painter path. The lines are all drawn with cosmetic pens of various thicknesses > 1.

    What I am trying to do is draw a line of a given thickness that has a single pixel 'end cap' in a different color, for example:
    |=============|

    Where | is an end cap and = represents the main line.

    This should allow me to draw two lines of the same color and have a single pixel demarcation between them (it may have two pixels in the middle, but that is fine too):
    |==============|==============|

    I can think of two ways to attack this:

    1. Draw the line in the 'end cap' color and then draw a second line shorter by two pixels (one at either end) over the top
    2. Draw the line and then draw another perpendicular line at each end, this line would use a cosmetic pen of width 1.

    The issue with 1 is that I am not sure how to make the line shorter by the equivalent of 2x the end cap width.

    The issue with 2 is that i do not know how to draw a line as long as the pen is wide.

    I suspect the answer lies in using some of the translations between coordinate systems, but I cannot work out where to start.

    Many 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