0
votes

I have a Qt (4.7.4) application, which is a graphic terminal for other applications. In QML I have defined Views with (named) controls. In C++ I receive commands from applications which request to show a view with specified values for my controls. When the command comes, I use something like

myView = LoadTheNewViewIntoLoader(viewName);
QObject* ctrl = myView->findChild<QObject*>(ctrlName);
if(ctrl)
{
  ctrl->setProperty("caption", newCaption);
}

to update the control value (i.e. change text, image or whatever).

Question: How quick is such an operation? Or: How can I be sure that all of the properties have been applied to the controls?

The problem is that in C++ I create a semaphore for the action of loading view and setting all of the properties, but when there are many commands coming during stress test, I have feeling that the values do not have ehough time to propagate from C++ to QML and when I'm performing next command, the previous actions are still executing. In such a situation the controls disappear from the screen at all for some time and sometimes I get even the Segmentation Fault. This is easier to achieve for more complicated screens with big number of controls.

1

1 Answers

0
votes

Decouple your design for performance / load handling.

Using SLOTS , SIGNALS

Let the C++ handle the logic and Qml the controls, viewer

Something like myView = LoadTheNewViewIntoLoader(viewName);

QObject* ctrl = myView->findChild<QObject*>(ctrlName);

if (ctrl)
{
    emit sgnShowcaption("newCaption");
}

Handle in qml this signal and set .label = str (str shall be in the signal you caught)