qt - All QT Quick Application crash after 3 seconds
问题描述
I can run a boilerplate QT Quick Application (empty project) fine - the window shows and does not crash. If I then update the QML with some simple controls and run the application it shows the window for 3 seconds then crashes. This problem occurs when I run the example QT Quick application projects aswell.
The application output window shows:
The program has unexpectedly finished.
The process was ended forcefully.
What is going wrong and how can I fix this?
Information:
I am on Windows 10 64bit, using QT Creator, the project using QMake and mininum QT version allowed is 5.9
I am compiling in Debug mode using Desktop QT 5.11.1 MSVC2017 64bit. Note I am not able to compile in any other settings (MSVC2015, MinGW) - I get errors. If I compile in Release mode I still experience the same crash.
Desktop QT 5.11.1 MSVC2017 64bit does have an exclamation mark next to it
No debugger setup
The following QML works:
import QtQuick 2.11
import QtQuick.Window 2.11
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
}
This causes it to crash:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: 'File'
}
}
header: ToolBar {
RowLayout {
}
}
TextArea {
id: area
anchors.fill: parent
}
}
解决方案
我也遇到了这个崩溃,窗口上只有一个矩形。
对我来说,通过在实例化我的 QGuiApplication 之前添加以下行来修复崩溃:
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
从文档中,在 Windows 上,这告诉 qt 使用角度。Angle是将opengl翻译成directx的驱动程序
您可以在http://doc.qt.io/qt-5/windows-requirements.html上阅读有关不同驱动程序选项的更多信息
推荐阅读
- rest - How to pass a map as query parameter
- ansible - Issue using Ansible's inventory plugin for AWS EC2
- mysql - How to mimic unique_together behaviour for many-to-many fields?
- ruby-on-rails - Rails code refactor in call method to handle map
- html - Is it possible to make an input type number fit to the width of the number it's displaying?
- c++ - Use cases for std::remove_if without std::erase
- node.js - Testing module that requires a module from a layer in AWS Lambda
- javascript - How to change logo src, when clicked on hamburger menu?
- javascript - Gain access to child elements under HTMLCollection's
- azure - How to upload to azure blob from a dataset or a datatable