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. How to draw a static graph like structure using canvas in QML?
QtWS25 Last Chance

How to draw a static graph like structure using canvas in QML?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.7qmlcanvas
2 Posts 2 Posters 551 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.
  • V Offline
    V Offline
    vinaygopal
    wrote on last edited by
    #1

    i am very new to Canvas side of QML so how can i get this kind of a structure using only Canvas in QML . just like the image 0f509f71-79eb-4875-83c8-771c8fde3b50-image.png .

    i was only able to draw the line and add the horizontal lable, i need to know how to draw the vertical label and the arrows.

     Canvas {
                    id: chirp_canvas
                    width: parent.width
                    height: parent.height
                    scale:1.05
                    onPaint: {
                        var ctx = getContext("2d");
                        ctx.reset();
                        ctx.lineWidth=3;
                        ctx.beginPath();
                        ctx.moveTo(10, 500)
                        ctx.lineTo(10, 40); // how to add arrow
    
                        ctx.fillText("Frequency",5,200) // how to make this a vertical text
                        ctx.stroke();
    
                        ctx.beginPath();
                        ctx.moveTo(10,500);
                        ctx.lineTo(600,500);  //how to add arrow
                        ctx.stroke();
                    }
    
                }
    
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You will get better performance (and more help from Qt docs) if you use QQuickPaintedItem and draw this in C++.

      (Z(:^

      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