Qt World Summit: Register Today!

Runtime error on connect

  • I've been trying to connect a signal to a slot and it compiles but once the connect function is run the program the thread gets stuck processing connect for maybe one second before crashing. I must be calling the connect error incorrectly but I can't figure out how. I've included the relevant sections of code below.

    //It runs until the connect function but never reaches the debug code.
    void MainWindow::importThreads(TimerThread* t, AiThread* a){
    worker = t->getThread();
    aiThread = a;
    qDebug() << "Connected!";

    //This is the slot. This code is never run.
    void MainWindow::refreshPosition(){
    //Declaration of Signal in Worker class
    void timeout();

    //Declaration of slot in the MainWindow class
    public slots:
    void refreshPosition();

  • You don't run MainWindow in a thread other than main, right?
    What is value of worker? Can it be nullptr?

  • You were right about the worker object being a invalid. It turns out the worker pointer in timer thread had yet to be initialized. Thanks.

Log in to reply