You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS(ARM)环境下QMessageBox::information引发应用崩溃求助

Qt项目msgtest中QMessageBox调用崩溃问题

项目文件内容

msgtest.pro

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

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

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_pushButton_clicked();

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

main.cpp

#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
   QMessageBox::information(nullptr, "Login success.", "You have successfully logged in!");
}

界面说明

主界面包含一个按钮,点击按钮会触发on_pushButton_clicked槽函数。

核心问题

点击按钮触发槽函数时,调用QMessageBox::information(nullptr, ...)直接导致程序崩溃,macOS弹出崩溃报告提示。已自行搜索解决方案两天未解决,寻求帮助。

环境配置

  • 设备:MacBook Air M2(ARM架构)
  • 系统:macOS Sonoma 14.0
  • IDE:Qt Creator 11.0.3
  • Qt工具链:配置适配ARM架构的Qt版本

调试器输出

  1. 调试输出1显示程序崩溃触发点位于Qt内部代码中,附带进程基础信息
  2. 调试输出2显示堆栈跟踪信息,指向QMessageBox::information的调用流程

内容的提问来源于stack exchange,提问作者Vladyslav Rehan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 14:13:20