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. Custom dash pattern
Forum Update on Monday, May 27th 2025

Custom dash pattern

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.5k 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.
  • S Offline
    S Offline
    StaticWorld
    wrote on 20 Nov 2014, 07:15 last edited by
    #1

    Hi,

    I have a custom dash pattern that I have which i use to draw the outline of a box of variable size. The setting up of the line is as follows:
    @QVector< qreal > dashes;
    qreal space = 6;
    qreal dashWidth = 4;
    dashes << dashWidth << space;
    pen.setDashPattern(dashes);
    @

    However when i am zooming using QGraphicsView, the dashes seems "cycle" around the border which i do not want. Is there a way which i remove the "cycling" effect?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on 20 Nov 2014, 08:16 last edited by
      #2

      I doubt this has anything to do with your custom dash pattern. Have you tried it with the standard dash pattern? Does it behave the same?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        StaticWorld
        wrote on 20 Nov 2014, 08:54 last edited by
        #3

        Yes, the standard dash pattern behaves the same

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on 20 Nov 2014, 11:09 last edited by
          #4

          I assume this behavior is by design: The length of line segments and gaps is the same regardless of the zoom level.

          However, if you have, for example, a rectangle, the total length of the circumference is different depending on zoom level. If the total line length changes, then the end of the line might show a gap where before it showed a line segment.

          There is no clean solution. If what you want is a dashed line where the dash length changes with the zoom level, you need to do that with the geometry of the graphic object you use, not with a dash pattern.

          1 Reply Last reply
          0

          1/4

          20 Nov 2014, 07:15

          • Login

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