Solved error: undefined reference to `MyThread::Timer_Slot()'
-
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);
}
-
Please read your error message again and then look where you have implemented your function.
-
@Christian-Ehrlicher Sorry, i realized it now. Can i delete this post?
-
@suslucoder said in error: undefined reference to `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.
-
@suslucoder
Don't worry, just mark @Christian-Ehrlicher's answer as the "solution" from the vertical dots button at the right of his message :)