首页 > 解决方案 > 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:

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
    }
}

标签: qtqml

解决方案


我也遇到了这个崩溃,窗口上只有一个矩形。

对我来说,通过在实例化我的 QGuiApplication 之前添加以下行来修复崩溃:

QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);

从文档中,在 Windows 上,这告诉 qt 使用角度。Angle是将opengl翻译成directx的驱动程序

您可以在http://doc.qt.io/qt-5/windows-requirements.html上阅读有关不同驱动程序选项的更多信息


推荐阅读