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. error: undefined reference to `MyThread::Timer_Slot()'
Qt 6.11 is out! See what's new in the release blog

error: undefined reference to `MyThread::Timer_Slot()'

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 859 Views
  • 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.
  • D Offline
    D Offline
    deleted286
    wrote on last edited by
    #1

    What does it mean? I have timer_slot in header file.

    #include "mythread.h"
    #include "mainwindow.h"
    #include <QtCore>
    #include <QDebug>
    #include <QFile>
    #include <QTimer>
    #include <QThread>
    #include <QMutex>
    #include <QQueue>
    #include <QMessageBox>
    #include <QApplication>
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QMainWindow>
    #include <QFileDialog>
    #include <QMainWindow>
    #include <QTimer>
    #include <QtCharts/QLineSeries>
    #include <QtCharts/QChartView>
    #include <QLineSeries>
    
    QT_CHARTS_USE_NAMESPACE
    using namespace QtCharts;
    
    QFile file("C:/Users/ilknu/Documents/MyThread/deneme.txt");
    
    MyThread::MyThread(QObject* parent)
        : QThread(parent)
    {
        writeData();
        initChartView();
        Timer_Slot();
        connect(timer, SIGNAL(timeout()), SLOT(Timer_Slot()));
        timer->start();
        timer->setInterval(500);
    
    }
    
    MyThread::~MyThread()
    {
    
    }
    
    void MainWindow::Timer_Slot()
    {
        static float q_x;
        if(!queue.isEmpty())
        {
            double num=queue.dequeue();
            q_x += 0.1;
            series->append(q_x, num);
            chart->update();
            // qDebug << q_x << num;
        }
    }
    
    void MyThread::writeData()
    {
    
        QFile::copy("C:/Users/ilknu/Documents/MyThread/deneme.txt", "C:/Users/ilknu/Documents/MyThread/yeniden.txt" );
        QFile file2("C:/Users/ilknu/Documents/MyThread/yeniden.txt");
        if(file.open(QIODevice::ReadOnly)) {
            QTextStream in(&file);
            while (!in.atEnd())
            {
                QString line2=in.readLine();
                QStringList list2 = line2.split(QLatin1Char(' '), Qt::SkipEmptyParts);
                for(const QString &entry : list2)
                {
                    double num = entry.toDouble();
                    queue.enqueue(num);
                    qDebug() << num;
                }
            }
        }
        qDebug() << "Source exists?" << QFile::exists("C:/Users/ilknu/Documents/MyThread/deneme.txt");
        qDebug() << "Destination exists?" << QFile::exists("C:/Users/ilknu/Documents/MyThread/budosyayok.txt");
        qDebug() << "im working in writing thread";
    
        emit writingDone();
    
    }
    
    void MyThread::run()  //Reading file from txt with thread1
    {
        if (file.open(QIODevice::ReadOnly))
        {
            QTextStream in (&file);
            while (!in.atEnd())
            {
                QString line = in.readAll();
    
                qDebug()<< "im running on worker thread " <<line;
    
            } // for
        } // while
        file.close();
    } // if
    
    void MyThread::initChartView()
    {
    
        QChart *chart = new QChart();
        chart->addSeries(series);
        qDebug() << series;
        QPen green(Qt::red);
        green.setWidth(2);
        series->setPen(green);
        chart->legend()->hide();
        chart->setTitle("deneme");
        chart->setAnimationOptions(QChart::AllAnimations);
    
        QValueAxis *axisX = new QValueAxis;
        axisX->setTickCount(10);
        axisX->setRange(0,5);
        axisX->applyNiceNumbers();
        chart->addAxis(axisX, Qt::AlignBottom);
        series->attachAxis(axisX);
    
        QValueAxis *axisY = new QValueAxis;
        axisY->setTickCount(10);
        axisY->setRange(0, 5);
        axisY->applyNiceNumbers();
        chart->addAxis(axisY, Qt::AlignLeft);
        series->attachAxis(axisY);
    
        QChartView *chartView = new QChartView(chart);
        chartView->setRenderHint(QPainter::Antialiasing);
    

    }

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please read your error message again and then look where you have implemented your function.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Please read your error message again and then look where you have implemented your function.

        D Offline
        D Offline
        deleted286
        wrote on last edited by
        #3

        @Christian-Ehrlicher Sorry, i realized it now. Can i delete this post?

        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • D deleted286

          @Christian-Ehrlicher Sorry, i realized it now. Can i delete this post?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @suslucoder said in error: undefined reference to &#x60;MyThread::Timer_Slot()':

          Can i delete this post?

          No, you should simply mark it as solved. And maybe the next time read and think first before you post.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • D deleted286

            @Christian-Ehrlicher Sorry, i realized it now. Can i delete this post?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @suslucoder
            Don't worry, just mark @Christian-Ehrlicher's answer as the "solution" from the vertical dots button at the right of his message :)

            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