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. Qml Canvas in SplitView: on resizing the canvas the context disappear
Forum Updated to NodeBB v4.3 + New Features

Qml Canvas in SplitView: on resizing the canvas the context disappear

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

    Dear friends,

    i hope somebody can help me.
    I use a canvas in a splitview. the canvas item has minWidth , so that i can shrink it to minimum width.

    But here came an error. Than i resize (use the splitview) the all painted content disappear!

    my code looks like:
    main.qml:
    @...
    SplitView{
    id:spitview
    anchors.fill: parent;

        Item{
            Layout.fillWidth: true;
            Layout.fillHeight: true;
            Viewer{
                anchors.fill: parent;
                anchors.margins: 5;
            }
        }
    
        Item{
            width: parent.width/4;
            Layout.minimumWidth: parent.width/4;
            Layout.maximumWidth: parent.width/4+100;
            Layout.fillHeight: true;
        }
    }@
    

    Viewer.qml:
    @
    Canvas{
    anchors.fill:parent
    onPaint: [paint some stuff]
    }
    @

    Please help me, i dont want to use a constant size for the canvas-item. Thanks.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bux52
      wrote on last edited by
      #2

      I did it.

      Following Code solve my problem:

      @Canvas{
      ...
      onWidthChanged: {
      var ctx = getContext('2d');
      ctx.reset();
      [draw some stuff]
      }
      }@

      Bux52

      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