gpt4 book ai didi

c++ - Qt "The program has unexpectedly finished."关闭

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:44:10 25 4
gpt4 key购买 nike

我有一个关于 QML 2 (Qt 5.2.1) 的项目。似乎可以正常工作。

但是当我在 Qt Creator 的“应用程序输出”(底部的那个东西)中关闭正在运行的项目(ALT+F4 或其他)时,在 1-2秒,我收到以下消息:

The program has unexpectedly finished.
bla-bla-bla.exe crashed

这发生在发布和 Debug模式中。我在调试下启动,但没有收到任何错误。我从最后一个析构函数开始一步一步地进行,直到返回 1 的 return app.exec();

我的意思是除了这个 - 我没有看到任何错误。我应该为此担心吗?我可以知道此消息的原因吗?有没有办法获得更具体的消息?


我尝试从 cmd 启动应用程序,但没有收到任何错误。我的main.cpp:

#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include "painter.h"

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);

qmlRegisterType<Painter>("MyCanvas", 1, 0, "MyCanvas");

QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/test_painteditem/main.qml"));
viewer.showExpanded();

return app.exec();
}

main.qml:

import QtQuick 2.0
import MyCanvas 1.0

Rectangle {
width: 360
height: 360
color: "white";
focus: true;
Keys.onLeftPressed: {
mc.frame--;
mc.update();
}
Keys.onRightPressed: {
mc.frame++;
mc.update();
}
Keys.onPressed: {
if (event.key === Qt.Key_C){
mc.switchCurve();
}else if (event.key === Qt.Key_O){
mc.switchCurveOffset();
}
}

MouseArea {
anchors.fill: parent
onClicked: {
// mc.x += 10;
//mc.update();
if (!tim.running){
tim.start();
} else {
tim.stop();
}
}
onWheel: {
if (wheel.angleDelta.y > 0)
mc.zoomIn();
else
mc.zoomOut();
}
onPressed: {
}
}

Timer {
id:tim
interval: 1; running: false; repeat: true
onTriggered: {
mc.frame++;
mc.update();
}
}

MyCanvas {
id:mc;
x:0;
y:0;
width:1000; /** 2000x2000 not supported in Android */
height:1000;
}
}

最佳答案

有一个app.quit()退出 Qt 应用程序时可以调用或连接的方法。除此之外,返回值 1 可能不是 Qt 创建者所期望的。您希望返回值等于 EXIT_SUCCESS(或 0)。

关于c++ - Qt "The program has unexpectedly finished."关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24487186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com