Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-21916

Canvas disables smooth feature if renderTarget is not Canvas.Image

    XMLWordPrintable

Details

    • afaeabeb5a4344b4e05c98e665e8bf6d86594738

    Description

      It appears that Canvas disables the "smooth" capability if the canvas renderTarget is not set to Canvas.Image (even if smooth is set to true).

      I've attached an image that shows the output when the renderTarget is not set to Canvas.Image.

      import QtQuick 2.0
      
      Rectangle {
         width: 600; height: 500
      
         focus: true
         Keys.onReturnPressed: {
             print('repainting...')
             canvas.requestPaint()
         }
      
         Canvas {
           id: canvas
           width: parent.width
           height: parent.height
      
           smooth: true
           // renderTarget: Canvas.Image   // if this is set, rendered output is smooth
      
           onPaint: {
               var ctx = canvas.getContext('2d');
      
               ctx.beginPath();
               ctx.moveTo(75,25);
               ctx.quadraticCurveTo(25,25,25,62.5);
               ctx.quadraticCurveTo(25,100,50,100);
               ctx.quadraticCurveTo(50,120,30,125);
               ctx.quadraticCurveTo(60,120,65,100);
               ctx.quadraticCurveTo(125,100,125,62.5);
               ctx.quadraticCurveTo(125,25,75,25);
               ctx.lineWidth = 3
               ctx.closePath();
               ctx.strokeStyle = "steelblue";
               ctx.fillStyle = "yellow";
               ctx.fill();
               ctx.stroke();
               ctx.fillStyle="green";
               ctx.font = "Bold 15px";
      
               ctx.fillText("QML Rocks!", 35, 60);
           }
         }
      
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            charles Charles Yin (closed Nokia identity) (Inactive)
            bealam Bea Lam (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes