PDA

View Full Version : Virtual protected and private var



maddog_fr
17th November 2010, 15:22
Hi there. I am blocked on a problem since nearly two days i dont find any clue to progress. I am using libQXt to create a small webservice that will send back json string to a webbrowser client. The webservice work well but i have a problem with accessing private data from my class.

class WebService : public QxtWebServiceDirectory {

Q_OBJECT

public:
WebService(QxtAbstractWebSessionManager * sm , QObject * parent = 0);
virtual ~WebService();
addString(const QString& json);

protected:
void indexRequested (QxtWebRequestEvent *event);

private:

QStringList Gadgets;

};

case 1 :
if in the constructor I fill Gadgets with strings;
then i access Gadget from indexRequested (wich is called when a request is done by a client) I can access Gadgets content.

case 2: from outside of WebService I call the public method addString to add strings to Gadgets and in this case Gadgets seems to be empty when accessed from indexRequested

any ideas where it come from ? what I am missing ?
thx

[EDIT] See attachment debug1.jpg is the QStringList content while WebService->getGadget() is called (by a singleshot timer from outside the class).

debug2.jpg is the content of the list when called from webbrowser >> indexRequested()

tbscope
17th November 2010, 19:08
Please post a compilable minimal example.
The information you gave is not enough.

maddog_fr
18th November 2010, 10:54
here is a compilable example

5481

maddog_fr
19th November 2010, 12:25
I still dont understand ! this small example work as it should 5496

maddog_fr
19th November 2010, 16:14
Problem solved! nothing to do with protected or private ! I had two webservice runing

rootService and gService. I was adding data to gService but it was rootService that was answering requests.