Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Signals and Slots over multiple windows

$
0
0
Hello, I have set up a view- model type application with multiple windows ; I have set up the appropriate signals, I don’t know how to connect the signals to the slots over my class hierarchy which is in 3 levels MainWindow has _*plotWindow, *_has actual plot code, using qCustomPlot MainWindow has server has ListenWriteThread creates socket; ListenWriteThread creates dispData The dispData emits signals whenever it detects peaks in the incoming data. How do I connect it to the mainwindow/plotwindow for the actual graph plotting? Would it work something like: connect &peakData, setData() to this->Parent, plotData()? where is the connection made exactly? In the mainwindow? I have only got the hang of button click to launch activity connections so far :( My readready signal and corresponding slot are in the same class. #ifndef DISPDATA_H #define DISPDATA_H #include <QObject> #include <vector> class dispData : public QObject {     Q_OBJECT public:     dispData(QObject* parent);     void setPeakDepth(int val) {peakDepth = val;}     void setPeakRecoil(int val){peakRecoil = val;}     void setCompressionRate(int val){compressionRate = val;}     void setStartIndex(int val){startIndex = val;}     void addData(int val, int index); signals:     void setPeakDepth(int val) {peakDepth = val;}     void setPeakRecoil(int val){peakRecoil = val;}     void setCompressionRate(int val){compressionRate = val;}         private:     int startIndex;     int value;     int peakDepth;  //UPDATE VALUE EMITS SIGNAL     int peakRecoil;//UPDATE VALUE EMITS SIGNAL     int compressionCount; //UPDATE VALUE EMITS SIGNAL     int compressionRate;     std::vector<int> rawReads;     std::vector<int> rawIndex;   };   #endif // DISPDATA_H   #ifndef LISTENWRITETHREAD_H #define LISTENWRITETHREAD_H #include <QThread> #include <QTcpSocket> #include "dispdata.h" class dispData;   class listenWriteThread : public QThread {     Q_OBJECT   public:     listenWriteThread(int socketDescriptor, const QString &fortune, QObject *parent);       void run(); public slots:     void analyzeThis(); signals:     void error(QTcpSocket::SocketError socketError);   private:     QTcpSocket* tcpSocket;     int socketDescriptor;     QString text;     dispData* rawData;   };   #ifndef MAINWINDOW_H #define MAINWINDOW_H   #include <QMainWindow> #include <QtWidgets> #include "dynamicplots.h" #include "cprServer.h" namespace Ui { class MainWindow; } class dynamicPlots; class MainWindow : public QMainWindow {     Q_OBJECT   public:     explicit MainWindow(QWidget *parent = 0);     ~MainWindow();     void setPlotWindow(dynamicPlots* dp);   private slots:     void on_quitButton_clicked();       void on_pbFiles_clicked();         void plotDepth(int val);     void plotRecoil(int rec);     void plotRate(int rate);   private:     void setUpListener();     dynamicPlots *dPlot;  //SIGNAL HAS TO BE PROCESSED HERE     Ui::MainWindow *ui;     cprServer server; };

Viewing all articles
Browse latest Browse all 13965

Trending Articles