I have the 'msgtest' QtCreator project:
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!");
}
The important part is the pushButton
slot void MainWindow::on_pushButton_clicked()
in mainwindow.cpp:
void MainWindow::on_pushButton_clicked()
{
QMessageBox::information(nullptr, "Login success.", "You have successfully logged in!");
}
The problem is that when I click the button the program crashed and MacOS want me to send crash report to Apple. Why QMessageBox::information
wont work?
I am trying to find something about my situation on the web for 2 days without success. Hope You will help me out.
My setup: MacBook Air M2 (ARM), MacOS Sonoma 14.0, Qt Creator 11.0.3, Qt kit:
As @alagner mentioned, homebrew's Qt is kinda broken on apple silicon, so to solve this I have removed qt and qt-creator packages with brew and installed qt creator and libraries with https://www.qt.io/download-qt-installer . It's kinda sad that I cant just type
brew install qt qt-creator
anymore to boot strap qt workflow on new Mac from command line.BUT now, the
QMessageBox::information(nullptr, "Login success.", "You have successfully logged in!");
does not break the app.Thank you all guys!