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. [Solved] QML template exchange
Forum Updated to NodeBB v4.3 + New Features

[Solved] QML template exchange

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

    perhaps it would be good to have a section in the forum where we can exchange templates. for example i've compiled a very basic 'triangle' item

    @import QtQuick 2.4

    Canvas {
    id: triangle
    antialiasing: true

              property int triangleWidth: 60
              property int triangleHeight: 60
              property color strokeStyle:  "#ffffff"
              property color fillStyle: "#ffffff"
              property int lineWidth: 3
              property bool fill: false
              property bool stroke: true
              property real alpha: 1.0
              states: [
                  State {
                      name: "pressed"; when: ma1.pressed
                      PropertyChanges { target: triangle; fill: true; }
                  }
              ]
    
              onLineWidthChanged:requestPaint();
              onFillChanged:requestPaint();
              onStrokeChanged:requestPaint();
    
              signal clicked()
    
              onPaint: {
                  var ctx = getContext("2d");
                  ctx.save();
                  ctx.clearRect(0,0,triangle.width, triangle.height);
                  ctx.strokeStyle = triangle.strokeStyle;
                  ctx.lineWidth = triangle.lineWidth
                  ctx.fillStyle = triangle.fillStyle
                  ctx.globalAlpha = triangle.alpha
                  ctx.lineJoin = "round";
                  ctx.beginPath();
    
                  // put rectangle in the middle
                  ctx.translate( (0.5 *width - 0.5*triangleWidth), (0.5 * height - 0.5 * triangleHeight))
    
                  // draw the rectangle
                  ctx.moveTo(0,triangleHeight/2 ); // left point of triangle
                  ctx.lineTo(triangleWidth, 0);
                  ctx.lineTo(triangleWidth,triangleHeight);
    
                  ctx.closePath();
                  if (triangle.fill)
                      ctx.fill();
                  if (triangle.stroke)
                      ctx.stroke();
                  ctx.restore();
              }
              MouseArea{
                  id: ma1
                  anchors.fill: parent
                  onClicked: parent.clicked()
              }
    

    }
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The wiki could be used for that

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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