Important: Please read the Qt Code of Conduct -

Qt process ends forcefully when manipulating widgets

  • Greetings to all.

    I'm trying to run a Qt Widgets Application but everytime I try to modify a specific widget on a Dialog (not MainWindow, everything works fine in that file) the program crashes and the process end forcefully with the following messages:

    23:26:51: The program has unexpectedly finished.
    23:26:51: The process was ended forcefully.

    I'm not quite sure what is the situation here. I have an object that runs some queries in order to fill 6 QHash containers and a QSqlDatabase object as well as class members but that's it.

    TLDR: Program crashes when trying to access ui members and operations in a specific Dialog diferent from Main Window.

  • Qt Champions 2017

    Crash means you definitely accessing some invalid pointer. Can show your sample code where it fails ?

  • @dheerendra


    It happens with any Widget, wether it is a label, qlistwidget, qlineedit, etc.

    Is the ui pointer set up in a wrong way? This is the Dialog class:

    #ifndef STORE_H
    #define STORE_H

    #include <QDialog>
    #include <administrador.h>
    #include <QMessageBox>

    namespace Ui {
    class Store;

    class Store : public QDialog

    explicit Store(QWidget *parent = nullptr);

    Ui::Store *ui;
    administrador admin;
    QSqlDatabase db;

  • @dheerendra

    this is the constructor definition

    Store::Store(QWidget *parent) :
    ui(new Ui::Store)
    db = QSqlDatabase::database();

    QHash<QString,sucursal> sucursales = admin.getSucursales();
    QHash<QString, celular> celulares = admin.getCelulares();
    QHash<QString, solicitudCompra> solicitudes = admin.getSolicitudes();
    QHash<QString, compra> compras = admin.getCompras();
    QHash<QString, documento> documentos = admin.getDocumentos();
    QHash<QString, Cliente> clientes = admin.getClientes();
    sucursal sanAndres = sucursales["idSuc1"];
    sucursal sonata = sucursales["idSuc2"];
    sucursal pte = sucursales["idSuc3"];
    sucursal serdan = sucursales["idSuc4"];
    sucursal ange = sucursales["idSuc5"];
    QHash<QString,celular>::iterator celtemp;
    celular celtemporal;
    celtemp = celulares.find("idXR");
    QString zeze = celtemp.value().getAtributo(0);
    qDebug() << zeze;


  • Lifetime Qt Champion

    Hi and welcome to devnet,


    must be called prior to any access to anything you added through designer.

  • @SGaist

    Thanks a lot!

    This fixed the error annd the project now runs smoothly. I'm really new to this tool but I promise I'll never forget your help.

    God bless you, hope you have a great day.

Log in to reply