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. Canvas inside checkbox - how to draw border when checkbox unchecked
Forum Updated to NodeBB v4.3 + New Features

Canvas inside checkbox - how to draw border when checkbox unchecked

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

    I am trying to make custom checkbox and I have problem with border.

                    CheckBox
                    {
                        id: checkbox_finished
                        text: qsTr("Finished alarms")
                        checked: true
    
                        indicator: Rectangle
                        {
                            implicitWidth: rectangle_checkbox_alarm_finished.width
                            implicitHeight: rectangle_checkbox_alarm_finished.height
    //                        border.color: checkbox_finished.down ? "black" : "red"
                            border.color: "black"
                            border.width: 1
    
                            Rectangle
                            {
                                width: 20
                                height: 20
                                x: 0
                                y: 0
    //                            color: checkbox_finished.down ? "black" : "red"
                                color: "red"
                                border.width: 1
                                visible: checkbox_finished.checked
    
                                Canvas
                                {
                                    id: drawingCanvas
                                    width: rectangle_checkbox_alarm_finished.width
                                    height: rectangle_checkbox_alarm_finished.height
    
                                    anchors.fill: parent
                                    onPaint:
                                    {
                                        var ctx = getContext("2d")
    
                                        ctx.fillStyle = "white"
                                        ctx.fillRect(0,0,drawingCanvas.width ,drawingCanvas.height )
    
                                        ctx.lineWidth = 2;
                                        ctx.strokeStyle = "black"
                                        ctx.beginPath()
                                        ctx.moveTo(0, 0)
                                        ctx.lineTo(drawingCanvas.width, drawingCanvas.height)
                                        ctx.moveTo(drawingCanvas.width, 0)
                                        ctx.lineTo(0, drawingCanvas.height)
                                        //ctx.closePath()
    
                                        ctx.rect(0, 0, drawingCanvas.width, drawingCanvas.height)
    
                                        ctx.stroke()
                                    }
                                }
    
                            }
    
    
                        }
    

    d918d80f-5237-456e-b053-a316260cf099-obraz.png

    a8e633bb-5694-40e2-a3c0-67040497dd0a-obraz.png

    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