1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Qt Quickでコンソールに文字列出力

Posted at

QtQuick(QML)のConsole出力について、質問させて下さい。

QtCreatorでプログラムを実行すると、
console.log()を使用すると、Consoleに文字列が出力されますが、
Commad PromptやPowerShellコンソールからプログラムを起動すると、
console.log()の出力を標準出力に返されません。

別途、.proファイルに何かの設定が必要なのでしょうか?
お手数ですが、ご存知の方がいらっしゃいましたら教えて頂けないでしょうか?

■開発環境
OS:Windows 8.1(32bit)
IDE:Qt Creator3.0
Kits: Desktop Qt 5.2.0 MSVC2012 32bit

■ソースファイル

import QtQuick 2.1
import QtQuick.Controls 1.0

ApplicationWindow {
title: qsTr("Hello World")
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
}

}

Add more folders to ship with the application, here

folder_01.source = qml/Hello_QtQuick3
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01

Additional import path used to resolve QML modules in Creator's code model

QML_IMPORT_PATH =

The .cpp file which was generated for your project. Feel free to hack it.

SOURCES += main.cpp

Installation path

target.path =

CONFIG += console //自分で追加しました

Please do not modify the following two lines. Required for deployment.

include(qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri)
qtcAddDeployment()

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?