yufit_in_Japan
yufit_in_Japan

Reputation: 583

Why does not any message appear on console (console.log() in QtQuick apps)

I would like to display messages on command prompt, when I run a QtQuick application from command prompt.

Here is my source code for trial.

import QtQuick 2.1
import QtQuick.Controls 1.0

ApplicationWindow {
   title: qsTr("Console test")
   width: 640
   height: 480

   menuBar: MenuBar {
       Menu {
           title: qsTr("File")
           MenuItem {
               text: qsTr("Exit")
               onTriggered:{
                   Qt.quit();
               }
           }
           MenuItem {
               text: qsTr("Start")
               onTriggered: console.log("start button is pressed.")
           }
       }
   }

   Button {
       text: qsTr("Hello World")
       anchors.centerIn: parent
   }

}

In QtCreator IDE, it works as expected. (the message was displayed on the console of IDE when I clicked munu item "start".)

In command prompt, however, No message is displayed. Does anyone know why?

Although I read this article, I have no idea how to solve the problem.

Thanks in advance.

[ Configurations ]

OS: Windows 8.1(32bit) Kits: Desktop Qt 5.2.0 MSVC2012 32bit IDE: QtCreator 3.0

Upvotes: 2

Views: 2394

Answers (1)

László Papp
László Papp

Reputation: 53173

Since @peppe has not written any answer yet after his comment, I am now stealing all the glories from him!

You need to use CONFIG += console. As you seem to have figured out, it is better to start with a clean directory in trouble, just in case.

Upvotes: 5

Related Questions