[Qt-interest] Basic QThread question
Phil
phillor at telstra.com
Sat May 15 09:23:13 CEST 2010
On Thu, 13 May 2010 10:15:28 pm Sean Harmer wrote:
> Hi Phil,
>
> On Thursday 13 May 2010 11:17:51 Phil wrote:
> > On Fri, 7 May 2010 06:14:02 pm Sean Harmer wrote:
> >
> Does that help? If not can you specify the desired flow of logic more
> precisely?
Yes it does Sean, however, I'm hung up on something that is probably basic
C++ rather than a logic error. At the risk of being jumped on, here is the
problem. After getting nowhere for most of the past two days I now realise
that I have two instances of classA. Once this is sorted out I should be able
to get the flow of the programme correct.
SelectItem is a slot that is called when an item is selected from a drop down
list on the main window.
void Pest::selectItem(const QString &listItem)
{
emit stop(); //stop the poller - this may not be necessary
Class_A classA; //this type is defined in the Pest header file
// Class_A's private attributes are initialised with valid data as follows
classA.getInitialValues(QString, double, double, etc);
emit start(); //restart the poller
}
void DevicePoller::poll()
{
// Talk to your device here. Since I do not have a device
// I will simply generate a psuedo-random number
int x = qrand() % 10;
// Let the world know that we have a new value
emit value( x );
QStringList list = classA.getData();
//classA is not the same instance as the classA type in the Pest class above
which means that list does not contain valid data. How do I organise the
same instance across two classes?
emit dataReady(list);
}
Maybe there is a more logical method to share data between classes.
Any help provided will, as always, be greatly appreciated.
--
Regards,
Phil
More information about the Qt-interest-old
mailing list