i have classes like this
class A : public QDialog
{
A(QWidget *parent);
static map<int,QString> dataa;
};
class B : public QThread
{
public void run();
}
class C : public QDialog
{
public void abc();
}
Defination of classes
void B::run()
{
in this function,i am using __dataa__ as __dataa.insert__which is defined initially in A class as public.
}
void C::abc()
{
in this function also,i am using __dataa__ as __dataa.find__ and dataa.end__ which is defined initially in A class as public.
}
Now please help me how can i use that variable dataa in the other two classes B and C.somewhere i seen we have to declare it as static and use it in the B and C class as A::data but its not working and giving error.
these three classes are initialized as
int main()
{
A window;
B datathread;
datathread.start
//B is Qthread inherited and A,C are QDialog inherited
}
class C is initialized from class A by clicking a pushbutton on it and opening its dialog in a new window. i guess this time i wont be blamed for not clearly formulating my question.please on gods name help me as i am stuck over this from long time.a big thanks in advance for any kind of help.
You need to define it in A's .cpp file. Say:
Also to make sure this is accessible elsewhere there are two options:
public
section of A classNow, to access this variable in other units, you would first include the header file for A class.
And to access it:
I am not familiar with QT but i guess this might help. If you want to use class'A data in class b or c there are three options
Access the class A's data through a public member function of class A like
public: