vladozar
18th February 2012, 20:13
HI
I'm trying to creat an Object that will contains some data and that will be avaliable to multiple Widgets. Also, if one Widget changes some data in the Object, next time some other Widget reads the data from Object, it will have the new chaged data.
For example.
Lets say we have
QWidget widgetA
QWidget widgetB
// more QWidgets are in my program, but for example purpose, we will use two widgets
// Both widgets are sepereate dialogs, widgets, mainWindows and have theier own classes and *.h and *.cpp files
// And some QObject that also has its own class and and *.h and *.cpp file
QObject sharedData
// And in the sharedData, lets say we have some public items (declared in the header file):
QString string
QString stringTwo
int number
What I wnat to do, is when widgetA changes some part of the sharedData Object,
// in the widgetA, some sharedData items are chaged like
sharedData->string = "apple";
sharedData->num = 10;
I need to be able that widgetB would read the changes made by widgetA
// lets say
qDebug()<<sharedData->string;
//will return "apple" and not an emtpy string
My question is how do i set up my object and how do I implament this object withing widgets:confused:. I know, I have to use pointers, but I have problem in initial setup.
Thanks to all. Hope to here from some one.:)
I'm trying to creat an Object that will contains some data and that will be avaliable to multiple Widgets. Also, if one Widget changes some data in the Object, next time some other Widget reads the data from Object, it will have the new chaged data.
For example.
Lets say we have
QWidget widgetA
QWidget widgetB
// more QWidgets are in my program, but for example purpose, we will use two widgets
// Both widgets are sepereate dialogs, widgets, mainWindows and have theier own classes and *.h and *.cpp files
// And some QObject that also has its own class and and *.h and *.cpp file
QObject sharedData
// And in the sharedData, lets say we have some public items (declared in the header file):
QString string
QString stringTwo
int number
What I wnat to do, is when widgetA changes some part of the sharedData Object,
// in the widgetA, some sharedData items are chaged like
sharedData->string = "apple";
sharedData->num = 10;
I need to be able that widgetB would read the changes made by widgetA
// lets say
qDebug()<<sharedData->string;
//will return "apple" and not an emtpy string
My question is how do i set up my object and how do I implament this object withing widgets:confused:. I know, I have to use pointers, but I have problem in initial setup.
Thanks to all. Hope to here from some one.:)