Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt process ends forcefully when manipulating widgets

Qt process ends forcefully when manipulating widgets

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elbix
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

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

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      E 2 Replies Last reply
      0
      • dheerendraD dheerendra

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

        E Offline
        E Offline
        elbix
        wrote on last edited by
        #3

        @dheerendra

        ui->label_nombre->setText(zeze);
        

        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
        {
        Q_OBJECT

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

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

        1 Reply Last reply
        0
        • dheerendraD dheerendra

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

          E Offline
          E Offline
          elbix
          wrote on last edited by
          #4

          @dheerendra

          this is the constructor definition

          Store::Store(QWidget *parent) :
          QDialog(parent),
          ui(new Ui::Store)
          {
          setWindowTitle("Tienda");
          db = QSqlDatabase::database();
          admin.fillContainers();

          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;
          ui->label_nombre->setText(zeze);
          
          ui->setupUi(this);
          

          }

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by SGaist
            #5

            Hi and welcome to devnet,

            ui->setupUi(this);
            

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            E 1 Reply Last reply
            4
            • SGaistS SGaist

              Hi and welcome to devnet,

              ui->setupUi(this);
              

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

              E Offline
              E Offline
              elbix
              wrote on last edited by
              #6

              @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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved