【QT】野指针报错The inferior stopped because it received a signal from the Operating System.

 运行的时候会崩溃,并提示如下错误:

 Signal received

 The inferior stopped because it received a signal from the Operating System.

 Signal name : SIGSEGV

 Signal meaning : Segmentation fault

这个错误说明程序中有野指针,断点以下很容易找出错误。
 

void PLCTempControl::on_actionHelp_triggered()
{
    QDialog *dialog = new QDialog();
    Ui::Dialog ui;
    ui.setupUi(dialog);
    dialog->setAttribute(Qt::WA_DeleteOnClose); // 关闭的时候delete
    dialog->setWindowTitle("通信协议");
    ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch );// 自适应列宽
    ui.tableWidget->horizontalHeader()->setSectionResizeMode(2,QHeaderView::ResizeToContents );// 适应单元格内容
    ui.tableWidget->horizontalHeader()->setSectionResizeMode(3,QHeaderView::ResizeToContents );// 适应单元格内容
    ui.tableWidget->horizontalHeader()->setSectionResizeMode(4,QHeaderView::ResizeToContents );// 适应单元格内容
    dialog->show();
}

出错在指针

ui.tableWidget->horizontalHeader();

指针非空,但是调动 “->函数” 时会报错;

因为指针指向的对象是临时变量,临时变量会在其函数结束时即被释放。
故 m_pCurSldRels 变为了一个野指针,在其他调动 “->函数” 时会报错。

改正:不能用指针,就直接定义为对象

在使用信号--槽之前示例化(new)指针也可以解决

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
An operating system is a program that manages a computer’s hardware. It also provides a basis for application programs and acts as an intermediary between the computer user and the computer hardware. An amazing aspect of operating systems is how they vary in accomplishing these tasks. Mainframe operating systems are designed primarily to optimize utilization of hardware. Personal computer (PC) operating systems support complex games, business applications, and everything in between. Operating systems for mobile computers provide an environment in which a user can easily interface with the computer to execute programs. Thus, some operating systems are designed to be convenient, others to be efficient, and others to be some combination of the two. Before we can explore the details of computer system operation, we need to know something about system structure. We thus discuss the basic functions of system startup, I/O, and storage early in this chapter. We also describe the basic computer architecture that makes it possible to write a functional operating system. Because an operating system is large and complex, it must be created piece by piece. Each of these pieces should be a well-delineated portion of the system, with carefully defined inputs, outputs, and functions. In this chapter, we provide a general overview of the major components of a contemporary computer system as well as the functions provided by the operating system. Additionally, we cover several other topics to help set the stage for the remainder of this text: data structures used in operating systems, computing environments, and open-source operating systems.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

米杰的声音

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值