簡體   English   中英

Qt“該計划意外完成。”關閉

[英]Qt “The program has unexpectedly finished.” on close

我有關於QML 2(Qt 5.2.1)的項目。 看起來效果很好。

但是當我在Qt Creator的“應用程序輸出”(底部的那個)中關閉運行項目( ALT + F4或其他)時,1-2秒后,我收到以下消息:

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

這在發布和調試模式下發生。 我在調試下啟動,但沒有任何錯誤。 我從最后一個析構函數開始逐步執​​行,直到return app.exec(); ,返回1。

我的意思是除了這個 - 我沒有看到任何錯誤。 我應該擔心嗎? 我能知道這條消息的原因嗎? 有沒有辦法獲得更具體的信息?


我嘗試從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;
    }
}

退出Qt應用程序時,可以調用或連接到app.quit()方法。 除此之外,返回值1可能不是Qt創建者所期望的。 您希望返回值等於EXIT_SUCCESS (或0 )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM