<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Qt6 Android app crashes on Redmi Note 8 Pro when QDialog is accepted]]></title><description><![CDATA[<p dir="auto">Hi everyone,</p>
<p dir="auto">I have a Qt 6 Android application that works fine on most devices (Samsung S22, Redmi Note 8, Emulator), but crashes on Redmi Note 8 Pro when I open a QDialog (like NewDevice) and press the Save button.</p>
<p dir="auto">Here’s a simplified overview of my setup:</p>
<p dir="auto">main.cpp</p>
<pre><code>#include "anapencere.h"

#include &lt;QApplication&gt;
#include &lt;QLocale&gt;
#include &lt;QTranslator&gt;
#include "veri/veritabani.h"
#include &lt;QStyleHints&gt;

void applySystemTheme()
{
    Qt::ColorScheme scheme = qApp-&gt;styleHints()-&gt;colorScheme();

    QString themeFile;

    if (scheme == Qt::ColorScheme::Dark)
        themeFile = ":/themes/dark.qss";
    else
        themeFile = ":/themes/light.qss";

    QFile file(themeFile);
    if (file.open(QFile::ReadOnly | QFile::Text))
        qApp-&gt;setStyleSheet(file.readAll());
}

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
    QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
    QApplication a(argc, argv);
    applySystemTheme();
    QObject::connect(qApp-&gt;styleHints(),
                     &amp;QStyleHints::colorSchemeChanged,
                     qApp,
                     [](){
                         applySystemTheme();
                     });
    veritabani::vt().load();

    anapencere w;
    w.show();

    auto sonuc = a.exec();

    veritabani::vt().save();
    return sonuc;
}

</code></pre>
<p dir="auto">anapencere.cpp (Main Window)</p>
<pre><code>anapencere::anapencere(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::anapencere)
{
    ui-&gt;setupUi(this);
    this-&gt;showMaximized();
    this-&gt;setFocusPolicy(Qt::StrongFocus);
    this-&gt;setFocus();
    qApp-&gt;installEventFilter(this);
    //Devices
    ui-&gt;leDevicesSearch-&gt;installEventFilter(this);

    ui-&gt;tblwgDevices-&gt;horizontalHeader()-&gt;setSectionResizeMode(QHeaderView::ResizeToContents);
    ui-&gt;tblwgDevices-&gt;horizontalHeader()-&gt;setStretchLastSection(true);
    ui-&gt;tblwgDevices-&gt;verticalHeader()-&gt;setVisible(false);
    ui-&gt;tblwgDevices-&gt;setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui-&gt;tblwgDevices-&gt;setSelectionBehavior(QAbstractItemView::SelectRows);
    ui-&gt;btnNewComp-&gt;setObjectName("primaryButton");
    ui-&gt;btnNewDevice-&gt;setObjectName("primaryButton");

    connect(ui-&gt;tblwgDevices,&amp;QTableWidget::itemSelectionChanged,this,&amp;anapencere::devtblwSecim);

    searchTimer1 = new QTimer(this);
    searchTimer1-&gt;setSingleShot(true);
    connect(ui-&gt;leDevicesSearch, &amp;QLineEdit::textChanged, this, [this](){
        searchTimer1-&gt;start(500);
    });
    connect(searchTimer1, &amp;QTimer::timeout, this, &amp;anapencere::devsearch);

    //Components
    ui-&gt;leCompSearch-&gt;installEventFilter(this);

    ui-&gt;tblwgComp-&gt;horizontalHeader()-&gt;setSectionResizeMode(QHeaderView::ResizeToContents);
    ui-&gt;tblwgComp-&gt;horizontalHeader()-&gt;setStretchLastSection(true);
    ui-&gt;tblwgComp-&gt;verticalHeader()-&gt;setVisible(false);
    ui-&gt;tblwgComp-&gt;setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui-&gt;tblwgComp-&gt;setSelectionBehavior(QAbstractItemView::SelectRows);

    connect(ui-&gt;tblwgComp,&amp;QTableWidget::itemSelectionChanged,this,&amp;anapencere::comptblwSecim);

    searchTimer2 = new QTimer(this);
    searchTimer2-&gt;setSingleShot(true);
    connect(ui-&gt;leCompSearch, &amp;QLineEdit::textChanged, this, [this](){
        searchTimer2-&gt;start(500);
    });
    connect(searchTimer2, &amp;QTimer::timeout, this, &amp;anapencere::compsearch);


}
void anapencere::showMessage(QMessageBox::Icon icon,
                             const QString &amp;title,
                             const QString &amp;text)
{
    if (QWidget *focused = qApp-&gt;focusWidget()) {
        focused-&gt;clearFocus();
    }
    QTimer::singleShot(150, this, [=]() {
        QMessageBox *msg = new QMessageBox(icon, title, text, QMessageBox::Ok, this);
        msg-&gt;setAttribute(Qt::WA_DeleteOnClose);
        msg-&gt;open();
    });
}
bool anapencere::eventFilter(QObject *obj, QEvent *event)
{
    if (qApp-&gt;activeModalWidget() != nullptr || qApp-&gt;activeWindow() != this) {
        return QObject::eventFilter(obj, event);
    }
    if (qobject_cast&lt;QLineEdit*&gt;(obj)) {
        return QObject::eventFilter(obj, event);
    }

    if (event-&gt;type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast&lt;QKeyEvent *&gt;(event);
        if (keyEvent-&gt;key() == Qt::Key_Backspace) {
            return QObject::eventFilter(obj, event);
        }

        if (keyEvent-&gt;key() == Qt::Key_Back || keyEvent-&gt;key() == Qt::Key_Escape) {
            if (ui-&gt;stackedWidget-&gt;currentIndex() != 0) {
                back();
                return true;
            }
            else {
                QMessageBox *msg = new QMessageBox(QMessageBox::Question,
                                                   "Çıkış",
                                                   "Uygulamadan çıkmak istiyor musunuz?",
                                                   QMessageBox::NoButton,
                                                   this);

                QPushButton *evetButonu = msg-&gt;addButton("Evet", QMessageBox::YesRole);
                msg-&gt;addButton("Hayır", QMessageBox::NoRole);

                connect(msg, &amp;QMessageBox::buttonClicked, this,
                        [=](QAbstractButton *btn){
                            if (btn == evetButonu)
                                QCoreApplication::quit();
                        });

                msg-&gt;setAttribute(Qt::WA_DeleteOnClose);
                msg-&gt;open();

                return true;
            }
        }
    }
    return QObject::eventFilter(obj, event);
}
//... other code
void anapencere::on_btnNewDevice_clicked()
{
    NewDevice *frm = new NewDevice(this);
    frm-&gt;setAttribute(Qt::WA_DeleteOnClose);
    auto device = veritabani::vt().devices()._new();
    frm-&gt;setData(device);

    connect(frm, &amp;QDialog::accepted, this, [=]() {
        *device = *frm-&gt;getData();

        auto existing = veritabani::vt().devices().search([device](DeviceTable::VeriPointer d){
            return d-&gt;getSerialnumber().toLower() == device-&gt;getSerialnumber().toLower();
        });

        if (!existing.isEmpty()) {
            showMessage(QMessageBox::Critical,
                        "Error",
                        QString("%1 serial number already exists!").arg(device-&gt;getSerialnumber()));
            return;
        }

        veritabani::vt().devices().add(device);
        veritabani::vt().save();
        showMessage(QMessageBox::Information,
                    "Info",
                    QString("%1 device added.").arg(device-&gt;getSerialnumber()));
        devsearch();
    });

    frm-&gt;open();  // Using open() instead of exec()
}
</code></pre>
<p dir="auto">anapencere.h (MainWindow)</p>
<pre><code>#pragma once
#include "veri/veritabani.h"
#include &lt;QMainWindow&gt;
#include &lt;QTimer&gt;
#include "ui/editcomponent.h"
#include "ui/editdevice.h"
#include "ui/newcomponent.h"
#include "ui/newdevice.h"
#include "ui/repairtasks.h"
#include &lt;qevent.h&gt;
#include &lt;QMessageBox&gt;

QT_BEGIN_NAMESPACE
namespace Ui {
class anapencere;
}
QT_END_NAMESPACE

class anapencere : public QMainWindow
{
    Q_OBJECT

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

    void devicesload();
    void devsearch();
    void devtblwSecim();

    void compload();
    void compsearch();
    void comptblwSecim();

    void showMessage(QMessageBox::Icon icon,
                     const QString &amp;title,
                     const QString &amp;text);
protected:
    bool eventFilter(QObject *obj, QEvent *event) override;
    void back();
private slots:
    void on_btnDevices_clicked();

    void on_btnComp_clicked();

    void on_btnRepairTask_clicked();

    void on_btnNewDevice_clicked();

    void on_btnDevicesEdit_clicked();

    void on_btnDevicesDel_clicked();

    void on_btnCompEdit_clicked();

    void on_btnCompDel_clicked();

    void on_btnNewComp_clicked();

    void on_btnBack_clicked();

    void on_btnBack2_clicked();

private:
    Ui::anapencere *ui;
    QTimer *searchTimer1;
    QTimer *searchTimer2;
    DeviceTable::VeriListesi deviceslist;
    ComponentTable::VeriListesi complist;
};
</code></pre>
<p dir="auto">NewDevice.cpp QDialog</p>
<pre><code>#include "newdevice.h"
#include "ui/ui_newdevice.h"

NewDevice::NewDevice(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::NewDevice)
{
    ui-&gt;setupUi(this);
    ui-&gt;dteEntryDate-&gt;setDateTime(QDateTime::currentDateTime());
    ui-&gt;btnSave-&gt;setObjectName("primaryButton");
}

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

DeviceTable::VeriPointer NewDevice::getData() const
{
    data-&gt;setSerialnumber(ui-&gt;leSerial-&gt;text());
    data-&gt;setModelName(ui-&gt;leModel-&gt;text());
    data-&gt;setCustomerName(ui-&gt;leCustomer-&gt;text());
    data-&gt;setEntryDate(ui-&gt;dteEntryDate-&gt;dateTime());
    auto n=ui-&gt;cbStatus-&gt;currentText();
    statusenum status;
    if(n=="Tamirde"){
        status = statusenum::Tamirde;
    }else if(n=="Tamamlandi"){
        status = statusenum::Tamamlandi;
    }else if(n=="Iade"){
        status = statusenum::Iade;
    }else if(n=="Testte"){
        status = statusenum::Testte;
    }else{
        status = statusenum::Beklemede;
    }
    data-&gt;setStatus(status);
    data-&gt;setFaultDescription(ui-&gt;teFaultDesc-&gt;toPlainText());

    return data;
}

void NewDevice::setData(DeviceTable::VeriPointer newData)
{
    data = newData;

    ui-&gt;leSerial-&gt;setText(data-&gt;getSerialnumber());
    ui-&gt;leModel-&gt;setText(data-&gt;getModelName());
    ui-&gt;leCustomer-&gt;setText(data-&gt;getCustomerName());
    ui-&gt;dteEntryDate-&gt;setDateTime(data-&gt;getEntryDate());
    statusenum status=data-&gt;getStatus();
    switch (status) {
    case statusenum::Beklemede:
        ui-&gt;cbStatus-&gt;setCurrentText("Beklemede");
        break;
    case statusenum::Iade:
        ui-&gt;cbStatus-&gt;setCurrentText("İade");
        break;
    case statusenum::Tamamlandi:
        ui-&gt;cbStatus-&gt;setCurrentText("Tamamlandı");
        break;
    case statusenum::Tamirde:
        ui-&gt;cbStatus-&gt;setCurrentText("Tamirde");
        break;
    case statusenum::Testte:
        ui-&gt;cbStatus-&gt;setCurrentText("Testte");
        break;
    default:
        ui-&gt;cbStatus-&gt;setCurrentText("Beklemede");
        break;
    }
    ui-&gt;teFaultDesc-&gt;setPlainText(data-&gt;getFaultDescription());
}

void NewDevice::on_btnSave_clicked()
{
    if (ui-&gt;leModel-&gt;text().trimmed().isEmpty()) {
        QMessageBox::warning(this, "Eksik Bilgi", "Lütfen Model Kısmını Boş Geçmeyiniz!");
        return;
    }
    if (ui-&gt;leSerial-&gt;text().trimmed().isEmpty()) {
        QMessageBox::warning(this, "Eksik Bilgi", "Lütfen Seri No Kısmını Boş Geçmeyiniz!");
        return;
    }
    if (ui-&gt;teFaultDesc-&gt;toPlainText().trimmed().isEmpty()) {
        QMessageBox::warning(this, "Eksik Bilgi", "Lütfen Arıza Açıklaması Kısmını Boş Geçmeyiniz!");
        return;
    }
    QDialog::accept();
}
</code></pre>
<p dir="auto">NewDevice.h QDialog</p>
<pre><code>#pragma once

#include &lt;QDialog&gt;
#include &lt;QMessageBox&gt;
#include "../veri/veritabani.h"

namespace Ui {
class NewDevice;
}

class NewDevice : public QDialog
{
    Q_OBJECT

public:
    explicit NewDevice(QWidget *parent = nullptr);
    ~NewDevice();

    DeviceTable::VeriPointer getData() const;
    void setData(DeviceTable::VeriPointer newData);

private slots:
    void on_btnSave_clicked();

private:
    Ui::NewDevice *ui;
    DeviceTable::VeriPointer data;
};
</code></pre>
<p dir="auto">Problem</p>
<p dir="auto">The app crashes only on Redmi Note 8 Pro when accepting the dialog.</p>
<p dir="auto">Works fine on Redmi Note 8, Samsung S22, and emulator.</p>
<p dir="auto">I suspect this could be related to pointer lifetimes, QDialog::open() vs exec(), or device-specific memory issues, but I can’t figure out why it happens only on this device.</p>
<p dir="auto">The DeviceTable::VeriPointer is stored in the main window after the dialog closes.</p>
<p dir="auto">Question</p>
<p dir="auto">Has anyone experienced QDialog crashes on specific Android devices after pressing accept?</p>
<p dir="auto">Could this be related to heap, pointer lifetime, or CPU architecture differences?</p>
<p dir="auto">How can I safely debug or prevent this crash on Redmi Note 8 Pro?<br />
Qt and Android Configuration:</p>
<pre><code>Qt Version: 6.10.2

Build Kit: Android arm64-v8a

Android Build-tools Version: 36.1.0

Android Platform SDK: android-36

Android Customization: None
</code></pre>
<p dir="auto">Device Testing:</p>
<pre><code>Samsung S22 : Works correctly.

Samsung S9 Fe (tablet) : Works correctly.

Android Studio Device Android 16.0 x86_64 : Works correctly.

Redmi Note 8: Works correctly.

Redmi Note 8 Pro: Crashes
</code></pre>
]]></description><link>https://forum.qt.io/topic/164268/qt6-android-app-crashes-on-redmi-note-8-pro-when-qdialog-is-accepted</link><generator>RSS for Node</generator><lastBuildDate>Thu, 14 May 2026 15:58:07 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164268.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 15 Feb 2026 15:44:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt6 Android app crashes on Redmi Note 8 Pro when QDialog is accepted on Sun, 15 Feb 2026 17:21:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
please provide a simple, compilable reproducer.<br />
Yours doesn't compile, because you are using a UI file which is not posted.<br />
It also would make the reproducer too large.</p>
<p dir="auto">My wild guess is that you have a use-after-free, which randomly works when the freed memory hasn't been re-used and crashes when it has been re-used.</p>
<p dir="auto">Either simplify this further, preferably into one single file.<br />
Or, at least, through debug statements in all your destructors and observe what happens.<br />
Please also provide a stack trace.</p>
]]></description><link>https://forum.qt.io/post/836306</link><guid isPermaLink="true">https://forum.qt.io/post/836306</guid><dc:creator><![CDATA[Axel Spoerl]]></dc:creator><pubDate>Sun, 15 Feb 2026 17:21:14 GMT</pubDate></item></channel></rss>