How can i get the data from my mythread object back to MainWindow.?
-
That queue variable belongs to your mythread class. So I cannot do any operations with queue.I want to access the datas into queue. They are in different classes. How can i do it?
mythread.h
class mythread: public QThread { Q_OBJECT public: mythread(QObject* parent = nullptr); ~mythread(); void run(); signals: void writingDone(); public slots: void writeData(); private: QQueue<double> queue; }; #endif // MYTHREAD_H
mainwindow.cpp
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(); } }
-
@suslucoder said in How can i get the data from my mythread object back to MainWindow.?:
How can i do it?
Using signals/slots...
-
@suslucoder I'm not going to write code for you. In your other thread @SGaist posted a link to signal/slot documentation. There is an example for a signal and a slot with a parameter. Do it like shown there...
-
@suslucoder Please stop deleting solved topics!
-
@Christian-Ehrlicher how can i check, whether the queue is empty or not? I connect queue object with signal and slot. But there is still no data in chart. It gives
QtCharts::QLineSeries(0x2e720e0)Datas could not add series, is it?
-
@suslucoder Do you actually read documentation? https://doc.qt.io/qt-5/qxyseries.html#count
-