Component.onCompleted with console.log not working, why please?
-
wrote on 27 Jul 2022, 16:13 last edited by Mlibu
Hi there. I have a brand new empty Python Qt5 QML project application to which I have added a console.log. Why is my console.log not visible in Application Output? I have seen many examples where they use this technique for debugging and never have a problem.
import QtQuick 2.15
import QtQuick.Window 2.15Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Component.onCompleted: { console.log("HEREHHERRHEHREHRHRE") } }
-
wrote on 27 Jul 2022, 16:58 last edited by
I found the answer to this question. In the build environment I needed to add "QT_FORCE_STDERR_LOGGING=1" to the environment. I'm not sure why STDERR works, when the console.log should be STDOUT but anyway that solved my problem.
-
wrote on 27 Jul 2022, 16:17 last edited by
@Mlibu said in Component.onCompleted with console.log not working, why please?:
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")Component.onCompleted: { console.log("HEREHHERRHEHREHRHRE") }
}
I tested it with qmlscene on Linux and log output is ok.
-
wrote on 27 Jul 2022, 16:23 last edited by
I have just noticed that it does come out on the command line but it is not displaying in Qt Creator in Application Output. Might you know why?
Thanks for the fast response, by the way.
Does qmlscene work on Windows? I am unable to use the design page in Qt Creator.
-
wrote on 27 Jul 2022, 16:58 last edited by
I found the answer to this question. In the build environment I needed to add "QT_FORCE_STDERR_LOGGING=1" to the environment. I'm not sure why STDERR works, when the console.log should be STDOUT but anyway that solved my problem.
-
I have just noticed that it does come out on the command line but it is not displaying in Qt Creator in Application Output. Might you know why?
Thanks for the fast response, by the way.
Does qmlscene work on Windows? I am unable to use the design page in Qt Creator.
-
I found the answer to this question. In the build environment I needed to add "QT_FORCE_STDERR_LOGGING=1" to the environment. I'm not sure why STDERR works, when the console.log should be STDOUT but anyway that solved my problem.
wrote on 27 Jul 2022, 17:15 last edited by JoeCFD@Mlibu said in Component.onCompleted with console.log not working, why please?:
QT_FORCE_STDERR_LOGGING
Good for you. I do not have this setting on Linux and am able to see log output in qt creator. Your output is not error message. This setting is kind of odd.
3/6