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. How can i get the data from my mythread object back to MainWindow.?

How can i get the data from my mythread object back to MainWindow.?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5chartsthreads
10 Posts 4 Posters 1.2k 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

    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();
    
        }
    
    }
    
    jsulmJ 1 Reply Last reply
    0
    • D deleted286

      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();
      
          }
      
      }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @suslucoder said in How can i get the data from my mythread object back to MainWindow.?:

      How can i do it?

      Using signals/slots...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      0
      • jsulmJ jsulm

        @suslucoder said in How can i get the data from my mythread object back to MainWindow.?:

        How can i do it?

        Using signals/slots...

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

        @jsulm I cant write the code for it, can you help me

        jsulmJ 1 Reply Last reply
        0
        • D deleted286

          @jsulm I cant write the code for it, can you help me

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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...

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          D 1 Reply Last reply
          1
          • jsulmJ jsulm

            @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...

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

            @jsulm ok.

            Christian EhrlicherC 1 Reply Last reply
            0
            • D deleted286

              @jsulm ok.

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

              @suslucoder Please stop deleting solved topics!

              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

                @suslucoder Please stop deleting solved topics!

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

                @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?

                jsulmJ 1 Reply Last reply
                0
                • D deleted286

                  @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?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @suslucoder Do you actually read documentation? https://doc.qt.io/qt-5/qxyseries.html#count

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  D 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @suslucoder Do you actually read documentation? https://doc.qt.io/qt-5/qxyseries.html#count

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

                    @jsulm Yes, i did.

                    J.HilkJ 1 Reply Last reply
                    0
                    • D deleted286

                      @jsulm Yes, i did.

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @suslucoder
                      alt text


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      1 Reply Last reply
                      1

                      • Login

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