Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Possible to draw dashed line using 2d context in Canvas?

Possible to draw dashed line using 2d context in Canvas?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 624 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.
  • C Offline
    C Offline
    cscooper
    wrote on last edited by
    #1

    I've got a Canvas on my window and I'm drawing a line on it:

    @
    Canvas
    {
    onPaint:
    {
    var ctx = getContext("2d");
    ctx.reset();
    ctx.beginPath();
    ctx.strokeStyle = "green";
    ctx.moveTo(0, 0);
    ctx.lineTo(100, 100);
    ctx.stroke();
    }
    }
    @

    But I would like the line to be dashed, not solid. Is there any way to do this? I tried setting the stroke style to a pattern:

    @
    var pat = ctx.createPattern("green", Qt.CrossPattern);
    ctx.strokeStyle = pat;
    @

    but none of the available patterns result in a good-looking dashed line.

    Any suggestions?

    Thanks,
    Chris

    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