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. Getting datas from queue to series
QtWS25 Last Chance

Getting datas from queue to series

Scheduled Pinned Locked Moved Solved General and Desktop
queuechartqt 5
5 Posts 2 Posters 736 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 6 Jan 2021, 08:47 last edited by
    #1

    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
      }
    
    J 1 Reply Last reply 6 Jan 2021, 08:54
    0
    • D deleted286
      6 Jan 2021, 08:47

      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
        }
      
      J Online
      J Online
      JonB
      wrote on 6 Jan 2021, 08:54 last edited by
      #2

      @suslucoder
      Assuming you have a QQueue<double> queue;, something like:

      double x = queue.dequeue();
      double y = queue.dequeue();
      series->append(x, y);
      
      D 1 Reply Last reply 6 Jan 2021, 09:05
      1
      • J JonB
        6 Jan 2021, 08:54

        @suslucoder
        Assuming you have a QQueue<double> queue;, something like:

        double x = queue.dequeue();
        double y = queue.dequeue();
        series->append(x, y);
        
        D Offline
        D Offline
        deleted286
        wrote on 6 Jan 2021, 09:05 last edited by deleted286 1 Jun 2021, 09:10
        #3

        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);
        
        J 1 Reply Last reply 6 Jan 2021, 09:24
        0
        • D deleted286
          6 Jan 2021, 09:05

          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);
          
          J Online
          J Online
          JonB
          wrote on 6 Jan 2021, 09:24 last edited by
          #4

          @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 cannot dequeue more then you have enqueued. Your enqueue() is fine. You will need something like:

          while (!queue.isEmpty())
          {
              double num = queue.dequeue();
              ....
          }
          
          D 1 Reply Last reply 6 Jan 2021, 11:13
          1
          • J JonB
            6 Jan 2021, 09:24

            @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 cannot dequeue more then you have enqueued. Your enqueue() is fine. You will need something like:

            while (!queue.isEmpty())
            {
                double num = queue.dequeue();
                ....
            }
            
            D Offline
            D Offline
            deleted286
            wrote on 6 Jan 2021, 11:13 last edited by
            #5

            @JonB Thank you, it works

            1 Reply Last reply
            0

            5/5

            6 Jan 2021, 11:13

            • Login

            • Login or register to search.
            5 out of 5
            • First post
              5/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved