Updating Pointer using signals and slots

Posted by Umesha MS on Stack Overflow See other posts from Stack Overflow or by Umesha MS
Published on 2010-04-14T12:16:52Z Indexed on 2010/04/14 12:43 UTC
Read the original article Hit count: 179

Filed under:
|

Hi,

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

I am using thread to perform intensive operation in back ground. 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 bellow 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 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.

Please tell me a way to send a pointer in a signal.

© Stack Overflow or respective owner

Related posts about qt

Related posts about c++