Getting datas from queue to series
-
Hi. I have a txt file. I read txt and add datas into a queue.
I want to create a char so, i should get datas from queue and put datas into series.
How can i get datas from queue and add them into series?double num = entry.toDouble(); qDebug()<<num; queue.enqueue(num); // I add datas into a queue
while(!queue.isEmpty()) { series->append(queue,queue); //no matching member function for call to append }
-
@suslucoder
Assuming you have aQQueue<double> queue;
, something like:double x = queue.dequeue(); double y = queue.dequeue(); series->append(x, y);
-
Assuming you have a
QQueue<double> queue;
, something like:Yes, i have it. It works. When i run my code it gives an error: ASSERT: "!isEmpty()" in file C:/Qt/5.15.2/mingw81_64/include/QtCore/qlist.h, line 361
And the program has unexpectedly finished. What might be the reason?
Edit: I guess my queue is empty. I try to add datas to series from an empty queue.
Is it wrong for add datas into a queue like as follows:
QFile file("C:/Users/ilknu/Documents/SnDeneme/deneme.txt"); if (file.open(QIODevice::ReadOnly)) { QTextStream in (&file); while (!in.atEnd()) { QString line = in.readLine(); //queue.enqueue(line); QStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts); for(const QString &entry : list) { double num = entry.toDouble(); qDebug()<<num; queue.enqueue(num);
-
@suslucoder said in Getting datas from queue to series:
Edit: I guess my queue is empty. I try to add datas to series from an empty queue.
Yes, doubtless you are trying to
dequeue
from an empty queue! You cannotdequeue
more then you haveenqueue
d. Yourenqueue()
is fine. You will need something like:while (!queue.isEmpty()) { double num = queue.dequeue(); .... }