Nominate our 2022 Qt Champions!

Send a value to output frame like Condole.log() or other with Qhick

  • Hello everyone, I'm trying to learn QtQhick, it's happening +/- well, but I would like to know how can I send a value to the application output at the bottom, like Console.log () or Cout , Trace () ..
    Thank in advance :)

  • @Alama hi

    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    Component.onCompleted : console.log("Hello World ! ")

    see here also :

    a nice book

  • Hi @LeLev , thank for speedy reply, but it'seem dont work for me, i try this

    color: "lightpink"
    console.log (color)

    Just to out values for tests when i problem

    My output frame say: Cannot assign to non-existent property "console"
    Same with c in upper case.. :)
    Im in créator 4.10.1 and my kit is Qt 5.12.5 MSCV 2012 64bit

    Sorry for my English..

  • @Alama

    console.log (color) this is javascript code, you cant write it just anywhere in the QML document ,
    see here

    function getY(){ // define js function
     return 10;
      // console.log()  cant write js code here directly 
      // you 'only' can 'write' the properties names of the SomeType   ex : x, y, height, width, ..... 
      x :  5 // here i assign 5 to x property
      y : getY() // call js function
     width : {return  5*5} // inline js  
    //for your example try 
    color: "lightpink"
    Component.onCompleted: console.log("defaut color is : " + color)
    onColorChanged : console.log("color changed to: " + color)

Log in to reply