Connection/Slot question
I have the following Class in creation that looks like so
- {
- Q_OBJECT
- public:
- bool Initialize();
- ~CQueryHandler();
- public:
- protected slots:
- private:
- QByteArray m_ByteArray;
- } g_QueryHandler;
- {
- }
- bool CQueryHandler::Initialize()
- {
- // Initialized Network Manager
- if (m_pNetworkManager == NULL) {
- return false;
- }
- // Setup Connections
- connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(QueryFinished(QNetworkReply*)));
- }
- {
- // TODO: Error checking
- // Perform Parsing and extra things from returned query
- // Extract Data from reply to a QByteArray Object
- m_ByteArray = pNetReply->readAll();
- }
This is just a rough outline of what i have. Pretty much i have CRequestHandler…Which will request my webserver for a particular Query and upon completion and retrieval of the information will perform some extra processing and parsing and save the information in my BYTEARRAY member.
If my program is using the above global object( g_QueryHandler ), and i have a simple dialog with a button the user can click, i understand how to send the QueryRequest as shown below
- void Dialog::Clicked()
- {
- g_QueryHandler.SendQuery("somequery to send to webserver");
- }
But what im unsure of is how to INFORM my Dialog:: that the request has finished and the above Dialog:: object can check the Query information returned from the request inside of g_QueryHandler.m_ByteArray member variable?
3 replies
Add this to CQueryHandler’s definition:
- signals:
- void queryFinished();
Add this to Dialog’s definition:
- public slots:
- void queryHandlerFinished();
Add this to Dialog:Dialog():
- connect( &g_QueryHandler, SIGNAL( queryFinished() ), SLOT( queryHandlerFinished() ) );
In the implementation of queryHandlerFinished() do whatever you want.
You must log in to post a reply. Not a member yet? Register here!



