私はFedora 23でQt 5.6を使用しており、console.log()
とconsole.debug()
はコンソールに何も書き込まないことに気付きました。私のコード例:コンソールにQML console.log()とconsole.debug()はコンソールに書き込まない
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
Component.onCompleted: {
console.warn("warn completed")
console.log("log completed")
console.error("error completed")
console.debug("debug completed")
console.exception("exception completed")
console.info("info completed")
}
}
}
プリント:
QML debugging is enabled. Only use this in a safe environment.
qml: warn completed
qml: error completed
qml: exception completed
onCompleted (qrc:/main.qml:16)
qml: info completed
そうwarn
、error
、exception
、そしてinfo
作業罰金。私は間違って何をしていますか?
編集#1: プロジェクトを新規に作成され、すべての私の情報源:
main.cppに
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
project.pro
TEMPLATE = app
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
編集#2: からの出力をコンパイルしますQt Creatorは、QT_NO_DEBUG_OUTPUT
,QT_NO_INFO_OUTPUT
、またはQT_NO_WARNING_OUTPUT
がないことを示しています。
14:43:36: Running steps for project project...
14:43:36: Configuration unchanged, skipping qmake step.
14:43:36: Starting: "/usr/bin/make"
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../project -I. -I../../Qt5.6.0/5.6/gcc_64/include -I../../Qt5.6.0/5.6/gcc_64/include/QtQuick -I../../Qt5.6.0/5.6/gcc_64/include/QtGui -I../../Qt5.6.0/5.6/gcc_64/include/QtQml -I../../Qt5.6.0/5.6/gcc_64/include/QtNetwork -I../../Qt5.6.0/5.6/gcc_64/include/QtCore -I. -I../../Qt5.6.0/5.6/gcc_64/mkspecs/linux-g++ -o main.o ../project/main.cpp
/home/krzys/Qt5.6.0/5.6/gcc_64/bin/rcc -name qml ../project/qml.qrc -o qrc_qml.cpp
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../project -I. -I../../Qt5.6.0/5.6/gcc_64/include -I../../Qt5.6.0/5.6/gcc_64/include/QtQuick -I../../Qt5.6.0/5.6/gcc_64/include/QtGui -I../../Qt5.6.0/5.6/gcc_64/include/QtQml -I../../Qt5.6.0/5.6/gcc_64/include/QtNetwork -I../../Qt5.6.0/5.6/gcc_64/include/QtCore -I. -I../../Qt5.6.0/5.6/gcc_64/mkspecs/linux-g++ -o qrc_qml.o qrc_qml.cpp
g++ -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,/home/krzys/Qt5.6.0/5.6/gcc_64/lib -o project main.o qrc_qml.o -L/home/krzys/Qt5.6.0/5.6/gcc_64/lib -lQt5Quick -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread
14:43:37: The process "/usr/bin/make" exited normally.
14:43:37: Elapsed time: 00:01.
あなたはリリースでビルドしましたまたはデバッグモード? info/debugはqDebugに翻訳されていると私は考えています。これはリリースモードでビルドされていると無効にすることができます。 –
ドキュメントによると、 'qDebug()'、 'qInfo()'、 'qWarning()'はデバッグツールです。コンパイル中に 'QT_NO_DEBUG_OUTPUT'、' QT_NO_INFO_OUTPUT'、または 'QT_NO_WARNING_OUTPUT'を定義してコンパイルすることができます。 – Tarod
@FrankOsterfeld:私のQt Creator(3.6.1)は、Debug、Profile、Releaseの3つのビルドを提供しています。 @Tarod:新しく作成したプロジェクトを使用しましたが、カスタム定義をソースまたは 'project.pro'ファイルに追加しませんでした。 質問はすべてのソースを含めるように編集されています。 –