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

Logging undefined when call console.log()

    XMLWordPrintable

Details

    • macOS

    Description

      When I am calling console.log("Some text") from QML, something like this:

      import QtQuick 2.12;
      import QtQuick.Window 2.12;
      
      Window {
      
      	visible: true;
      	width: 640;
      	height: 480;
      	title: qsTr("Hello World");
      
      	Component.onCompleted: {
      
      		console.log("Some notice");
      	}
      }
      

      Everything works fine, in log it's writing this:

       

      qml: Some notice

       

      But when I am calling the same console.log("Some notice"); from outside JS file (.pragma library),something like this:

       

      .pragma library
      
      function mTestFunction() {
      
      	console.log("Some notice");
      }
      
      import QtQuick 2.12;
      import QtQuick.Window 2.12;
      
      import "qrc:/test.js" as TEST;
      
      Window {
      
      	visible: true;
      	width: 640;
      	height: 480;
      	title: qsTr("Hello World");
      
      	Component.onCompleted: {
      
      		TEST.mTestFunction();
      	}
      }
      

       

      It's writing this:

      qml: Some notice
      qml: undefined

      The additional "qml: undefined" appearing only if calling console.log() from outside function.

       

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            bogong Alexandr KIRILOV
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes