c – Qt“程序意外结束了.”关闭
发布时间:2020-12-16 07:09:12  所属栏目:百科  来源:网络整理 
            导读:我有关于QML 2(Qt 5.2.1)的项目.看起来效果很好. 但是当我在Qt Creator的“应用程序输出”(底部的那个)中关闭运行项目(ALT F4或其他)时,在1-2秒后,我收到以下消息: The program has unexpectedly finished.bla-bla-bla.exe crashed 这在发布和调试模式下发
                
                
                
            | 
                         
 我有关于QML 2(Qt 5.2.1)的项目.看起来效果很好. 
  
  
但是当我在Qt Creator的“应用程序输出”(底部的那个)中关闭运行项目(ALT F4或其他)时,在1-2秒后,我收到以下消息: The program has unexpectedly finished. bla-bla-bla.exe crashed 这在发布和调试模式下发生.我在调试下启动,但没有任何错误.我从最后一个析构函数一步一步地跟着返回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,"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).
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
相关内容
- React 16 源码瞎几把解读 【三 点 一】 把react组件对象弄到
 - XML和JSON分别是什么?JSON有什么好处?
 - ios – 如何在应用程序商店xcode 4.4.1上安装XCode 4.5GM?
 - 【LeetCode】30. Substring with Concatenation of All Wor
 - fastjson把对象转化成json避免$ref
 - ruby-on-rails – 从number_to_currency中删除十进制[close
 - c# – 在linq foreach中调用一个方法 – 有多少开销?
 - c# – 当超时消息超时时,我们如何避免它们?
 - ajax 代码片段
 - postgresql – Heroku评论应用程序:复制数据库以审查应用程
 
