Note that there are some explanatory texts on larger screens.

plurals
  1. POfirst-chance exception access violation writing location inside QT clicked event
    text
    copied!<p>I have 2 version of the same application, in the version using a Graphical UI and QT I have a runtime error:</p> <pre><code>first-chance exception access violation writing location </code></pre> <p>referring to </p> <pre><code>this-&gt;secondi_totali = someint; </code></pre> <p>launched inside a Model Method. My Model class is:</p> <pre><code>class Model { public: friend class Controller; //dico che controller può accedere alle cose private //friend class cronometro_qt; /*costruttore*/ Model(); void set(int,int,int); int get_secondi(); int get_minuti(); int get_ore(); void tick(); private: int secondi_totali; int secondi_trascorsi; int secondi; int minuti; int ore; }; </code></pre> <p>the method causing the exception is this:</p> <pre><code>void crono::Model::set(int ore, int minuti, int secondi) { this-&gt;secondi_totali = ore * 3600 + 60 * minuti + secondi; this-&gt;secondi_trascorsi = 0; } </code></pre> <p>and in the stack is called from this method:</p> <pre><code>void crono::Controller::set(int ore, int minuti, int secondi) { this-&gt;modello-&gt;set(ore, minuti, secondi); } </code></pre> <p>this->modello is obviously a pointer to the Model object inside the Controller item.</p> <p>Well as I have previously said, I have done 2 versions of my program.</p> <p>In the first, the set() method of controller is called by a simple method of the view that is an empty class.</p> <p>In the second version the set() method of controller is called by a</p> <pre><code>void crono::cronometro_qt::on_pushButton_clicked() { /* ... */ } </code></pre> <p>method.</p> <p>Obviously in both version the empty view or the cronometro_qt ( subclass of QMainWindow ) have a pointer to the controller, in order to call the set() method like this:</p> <pre><code>this-&gt;controller-&gt;set(ore,minuti, secondi); </code></pre> <p>So why is the QT version throwing that exception?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload