I am having an issue using a QSlider to update a qwt plot. Essentially data is stored in a 2D vector (chan1data_p). When the slider moves the plot should replot the data in the given row of the 2D vector. The slider and qwt plot are placed in widget class where the curve 'chan1' is attached to the plot. When the program is run the first row of the vector is plotted but moving the slider has no effect on reploting. When I call updatePlots as a function the plot replots correctly. I checked the signal emited from the slider to make sure I set up the parameters for it correctly so that is not the problem. Anyone have any ideas?
private:
vector<double> ranges_p;
vector<vector<double> > chan1data_p, chan2data_p;
public slots:
void updatePlots(int profile);
protected slots:
void setProfile(int value);
private:
vector<double> ranges_p;
vector<vector<double> > chan1data_p, chan2data_p;
QVBoxLayout *layout;
QwtPlot *profilePlot;
QwtPlotCurve *chan1;
public slots:
void updatePlots(int profile);
protected slots:
void setProfile(int value);
To copy to clipboard, switch view to plain text mode
void graphPage::updatePlots(int profile)
{
vector<double> tempchan1,tempchan2;
int profile_index;
profile_index=profile-1;
if(profile<=chan1data_p.size() && !chan1data_p.at(profile_index).empty())
tempchan1=chan1data_p[profile_index];
if(!tempchan1.empty())
chan1->setData(&ranges_p[0],&tempchan1[0], ranges_p.size());
profilePlot->replot();
}
void graphPage::updatePlots(int profile)
{
vector<double> tempchan1,tempchan2;
int profile_index;
profile_index=profile-1;
if(profile<=chan1data_p.size() && !chan1data_p.at(profile_index).empty())
tempchan1=chan1data_p[profile_index];
if(!tempchan1.empty())
chan1->setData(&ranges_p[0],&tempchan1[0], ranges_p.size());
profilePlot->replot();
}
To copy to clipboard, switch view to plain text mode
connect(profileSlider,SIGNAL(valueChanged(int)),SLOT(updatePlots(int)));
connect(profileSlider,SIGNAL(valueChanged(int)),SLOT(updatePlots(int)));
To copy to clipboard, switch view to plain text mode
Bookmarks