Qt qBreakpad使用

环境:Windows10      qtcreator5.14    Debugging Tools for Windows(X64+X86)

源码:qBreakpad       Breakpad        LSS(linux-syscall-support)

1.将qBreakpad下载解压

 将Breakpad下载解压

将Linux Syscall Support下载解压

将Breakpad解压的文件放到qBreakpad下third_party下的breakpad下,将Linux Syscall Support解压的文件放到qBreakpad下third_party下的lss下。

 

 

 

 2.qBreakpad的编译方法

 用Qtcreator打开qBreakpad-master\handler\handler.pro单独编译

 编译运行后获得qBreakpad.lib

3.测试

打开Qtcreator新建一个项目

 在项目路径下新建文件夹3rdparty,并且把qBreakpad-master项目拷贝到3rdparty下,修改文件名为qBreakpad

修改项目配置文件

############
#qBreakpad
############
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = testCrash
TEMPLATE = app
#config for qBreakpad
#CONFIG -= app_bundle #配置上这个参数以后 你的图形界面程序就会以命令行方式运行,
CONFIG +=  warn_on
CONFIG += thread exceptions rtti stl
macx: LIBS += -framework AppKit
#without c++11 & AppKit library compiler can't solve address for symbols
CONFIG += c++11
#link qBreakpad library
include($$PWD/3rdparty/qBreakpad/qBreakpad.pri)
#end of config for qBreakpad

修改main.cpp

#include "widget.h"

#include <QApplication>
#include "QBreakpadHandler.h"

void crash()
{
    volatile int* a = (int*)(NULL);
    *a = 1;
}


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    // 设置生成dump文件路径
    QBreakpadInstance.setDumpPath(QLatin1String("crashes"));
    Widget w;
    w.show();
    crash();
    return a.exec();
}

测试运行,生成.dmp文件

///

linux下测试运行

 用Qtcreator打开qBreakpad-master/handler/handler.pro单独编译,生成Linux库文件

 新建一个linux的Qt项目,同样是新建一个3rdparty文件,将qBreakpad项目包含进去

修改项目配置文件

#-------------------------------------------------
#
# Project created by QtCreator 2021-09-02T10:59:09
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Test_qBreakpad
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
        main.cpp \
        widget.cpp

HEADERS += \
        widget.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

############
#qBreakpad
############
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = testCrash
TEMPLATE = app
#config for qBreakpad
#CONFIG -= app_bundle #配置上这个参数以后 你的图形界面程序就会以命令行方式运行,
CONFIG +=  warn_on
CONFIG += thread exceptions rtti stl
macx: LIBS += -framework AppKit
#without c++11 & AppKit library compiler can't solve address for symbols
CONFIG += c++11
#link qBreakpad library
include($$PWD/3rdparty/qBreakpad/qBreakpad.pri)
#end of config for qBreakpad

修改main.cpp

#include "widget.h"

#include <QApplication>
#include "QBreakpadHandler.h"

void crash()
{
    volatile int* a = (int*)(NULL);
    *a = 1;
}


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    // 设置生成dump文件路径
    QBreakpadInstance.setDumpPath(QLatin1String("crashes"));
    Widget w;
    w.show();
    crash();
    return a.exec();
}

编译运行,获得一个.dmp文件

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Qt Charts是一个用于绘制图表的Qt模块,可以使用它来创建各种类型的图表,如折线图、柱状图、饼图等。 在Qt 4中,Qt Charts模块是作为额外的附加模块提供的,因此需要单独安装。可以通过将qtcharts模块添加到.pro文件中的QT变量中来包含它。例如: ``` QT += charts ``` 使用Qt Charts绘制图表的过程一般包括以下几个步骤: 1. 创建一个Qt Charts的图表视图对象,用于显示图表。可以使用QChartView类来实现: ``` QChartView *chartView = new QChartView(); ``` 2. 创建一个Qt Charts的图表对象,并设置图表的类型和属性。例如,如果要创建一个折线图,可以使用QLineSeries类和QChart类: ``` QLineSeries *series = new QLineSeries(); series->append(0, 6); series->append(2, 4); series->append(3, 8); series->append(7, 4); QChart *chart = new QChart(); chart->addSeries(series); chart->createDefaultAxes(); chart->setTitle("Line Chart"); ``` 3. 将图表对象设置给图表视图对象,并使用布局将其添加到窗口中: ``` chartView->setChart(chart); layout->addWidget(chartView); ``` 4. 最后,显示图表窗口: ``` window->show(); ``` 以上是一个简单的示例,通过这些步骤可以绘制一个基本的图表。当然,在实际应用中,还可以根据需要设置更多的属性和样式,以及添加更多的系列数据。 需要注意的是,Qt Charts模块在Qt 5中已经成为了Qt的官方模块,因此在Qt 5中可以直接使用,无需额外安装。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值