Updating the pointer using signals and slot machines


I am very new to Qt; please help me to solve the problem.

I am using a thread to perform intensive operations in the background. Meanwhile I want to update the UI, so I am using SIGNALS and SLOTS. To update UI I emit a signal and update UI.

Let us consider below sample code,

struct sample
    QString name;
    QString address;

void Update(sample *);

void sampleFunction()
    sample a;
    a.name = "Sachin Tendulkar";
    a.address = "India"
    emit Update(&a);

In the above code we are creating a local object and passing the address of a local object. In the Qt document, it says that when we emit a signal it will be placed in the queue and late it will be delivered to the windows. Since my object is in local scope it will be delete once it goes out of the scope.

Is there a way to send a pointer in a signal?

You're insisting on doing the wrong thing, why? Just send the Sample itself:

void Update(sample);
sample a("MSalters", "the Netherlands");
emit Update(a);