When a user moves the slider it will trigger a signal and based on that I want to call a method readData
from dataClass
, to return me a string and then print it in guiClass
. But it does not work. I get Program received signal: “EXC_BAD_ACCESS”. I am using Xcode. As soon as I move the slider the program crashes and highlights line 9.
1 //---guiClass---
2 guiClass::guiClass(QWidget *parent) : QWidget(parent)
3 {
4 connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(slider_Moved(int)));
5 }
6 void guiClass::slider_Moved(int val)
7 {
8 //Don't worry about val for now.
9 cout << dataClassPtr->readData(val) << endl;
10 }
//---dataClass---
char* dataClass::readData(int lines) {
char *str = "hello world";
return str;
}