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. Dotted lines in QML
Qt 6.11 is out! See what's new in the release blog

Dotted lines in QML

Scheduled Pinned Locked Moved General and Desktop
qmlqt5.6
5 Posts 4 Posters 10.3k 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.
  • S Offline
    S Offline
    Soppe
    wrote on last edited by
    #1

    Hi,
    How to draw simple, dotted lines?
    I have an application that streams video from a webcamera. On top of this video i need to draw 4 corners of either solid lines, or dotted lines, so they mark a rectangle.
    I need to be able to change between solid lines and dotted lines dynamicly.
    I also need to be able to move these corners dynamicly.
    And i need to make the corners flash (draw, not draw, draw, not draw).

    I assume that i'll be able to solve the other problems once i've figured out how to properly draw dotted lines, but I'm adding it to create a better picture of what i want to achieve.

    The obvious way is to make a bunch of rectangles for each corner, and then make some of them transparent whenever i want a dotted line by setting some state property. As this is kind of hairy, I'm hoping there are better ways that does not drain a lot of resources.

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      Yakov Eremin
      wrote on last edited by
      #2

      May be BorderImage helps?

      S 1 Reply Last reply
      0
      • Y Yakov Eremin

        May be BorderImage helps?

        S Offline
        S Offline
        Soppe
        wrote on last edited by
        #3

        @Yakov-Eremin
        Seems to only be for images. I'm afraid i need something i can use on top of a live webcam stream. It's not supposed to work as a border, just as a marker in the middle of the screen. Pretty much like the upper left crosshair here.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Shahazan Ali
          wrote on last edited by Shahazan Ali
          #4

          Row/Column {
          anchors.centerIn: parent
          spacing: 10
          Repeater {
          model: 100 // or any number of dots you want
          Rectangle {width: 10; height: 2; color: "white"}
          }
          }

          J.HilkJ 1 Reply Last reply
          0
          • S Shahazan Ali

            Row/Column {
            anchors.centerIn: parent
            spacing: 10
            Repeater {
            model: 100 // or any number of dots you want
            Rectangle {width: 10; height: 2; color: "white"}
            }
            }

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @shahazan-ali
            wow, that's like using a hammer to tighten a screw!

            A simple Canvas element will do just fine

            Canvas{
            ...
                onPaint:{
                    var ctx = getContext("2d");
                    ctx.setLineDash([5, 15]);
            
                    ctx.beginPath();
                    ctx.moveTo(0,100);
                    ctx.lineTo(400, 100);
                    ctx.stroke();
                 }
            }
            

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            4

            • Login

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