Unsolved How to access values in QVector from other cpp files
-
Good afternoon,
Here's what I intend to do: I have a class SERIAL which contains 8 QVectors that hold values I'm receiving over serial port.
class SERIAL : public QObject { Q_OBJECT private: public: SERIAL(); ~SERIAL(); QVector<double> ch0_array, mean_ch0_array, ch1_array, mean_ch1_array, ch2_array, mean_ch2_array, ch3_array, mean_ch3_array, ch4_array, mean_ch4_array, ch5_array, mean_ch5_array, ch6_array, mean_ch6_array, ch7_array, mean_ch7_array; }
I want to plot each set of data in real time in 8 other classes each with its own QDialog, called plot0 to plot8. But I'm not able to understand how to share the data from this class to other classes.
I've tried includingserial.h
file to plot cpp files and I'm not able to access the vectors from there because of the errorinvalid use of non static data member
.Does anyone have an idea about this as I'm pretty bad in C++.
-
Hi,
first of all: your vectors belong inside the
private
section :) Then access them withget
functions.@Ketank16 said in How to access values in QVector from other cpp files:
I want to plot each set of data in real time
You could send the data by Signal&Slot mechanism
https://doc.qt.io/qt-5/signalsandslots.htmlWhat does your QDialog look like? Standard QDialog? What class / tool do you use for plotting?
-
Hi,
Based on your description, I would recommend going the model view way. That will allow you to have a cleaner structure and way to share your data.