qtimer crashes when created in constructor or static
<p>So, i have finally found this odd issue that i have found no answer for.</p>

<p>I'm creating a small gui, launching an application in a separate window and then polling the state of this app using a qtimer. </p>

<pre><code>    process_timer = new QTimer(this);
    connect(process_timer, SIGNAL(timeout()), this, SLOT(checkFlashProcess()));
    process_timer-&gt;start(100);
</code></pre>

<p>So this works. But i would rather not create a new timer every time, so i placed the creation of process_timer in the constructor of the gui:</p>

<pre><code>Flasher::Flasher(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Flasher)
{
    ui-&gt;setupUi(this);
    process_timer = new QTimer(this);
}
</code></pre>

<p>Now this leads to a crash and the output:
QObject::connect: Cannot connect (null)::timeout() to Flasher::checkFlashProcess()</p>

<p>Same for this:</p>

<pre><code>Flasher::Flasher(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Flasher),
process_timer(new QTimer)
{...
</code></pre>

<p>QTimer *process_timer is defined in the application header.</p>

<p>I have also tried defining process_timer as non dynamic:</p>

<pre><code>    header.h:
        QTimer process_timer;
    code.cpp
    void Flasher::on_flashButton_clicked()
    {
    (...)
    hProcess = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, process_pid );
    if(hProcess)
    {
        qDebug() &lt;&lt; "Got handle for process!";
        connect(&amp;process_timer, SIGNAL(timeout()), this, SLOT(checkFlashProcess()));
        process_timer.start(30);
    }
</code></pre>

<p>This also leads to a crash. </p>

<p>Callback:</p>

<pre><code> void Flasher::checkFlashProcess()
 {
        qDebug() &lt;&lt; "Got handle for process!";
 }
</code></pre>

<p>But Why is this? I guess that the timer does not get created in the constructor, but creating objects in the constructor should not be a problem right? And why would the static version crash also, would this be the same issue?</p>