Reputation: 3258
I'm trying to get a working QML app. It's all fine except the fact that when I run my app it opens the QML window but also a console window. Why? This is the code:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("myfile.qml"));
view.show();
return app.exec();
}
Rectangle {
width: 940
height: 670
color: red
}
Upvotes: 3
Views: 1564
Reputation: 11
For qbs set the property
consoleApplication: false
for your application.
For example:
Application {
// consoleApplication: false // permanently disable the console for the application
Properties {
condition: qbs.buildVariant == "debug"
consoleApplication: true //show console
}
Properties {
condition: qbs.buildVariant == "release"
consoleApplication: false //hide console
}
}
Upvotes: 1
Reputation: 555
For CMake users.
The problems occurred to me for MSVC and MinGW builds for Windows. (Even when not starting from an IDE.)
The solution were the following lines in CMakeLists:
if (WIN32)
set(WIN32_ON_OFF_SWITCH "WIN32")
else ()
set(WIN32_ON_OFF_SWITCH "")
endif ()
add_executable(SomeExe
${WIN32_ON_OFF_SWITCH}
#...
)
This exactly sets the target system away from console, like mentioned in a comment to the question.
Upvotes: 7
Reputation: 15
The console is for debugging with QDebug();
You can disable it by deleting line:
CONFIG += console
in your .pro file.
Upvotes: 1