Thank you for your inputs. The values are fetched only once and assigned to the *Text *element. This doesn't require any notification later as the data doesn't change in the app's lifetime. Hence, I haven't used Q_PROPERTY and notification signals. However, the *getStringData()* has some logic inside it before returning the string.
This issue is sometimes seen in low-end embedded hardware and does not appear at all in desktop and high-end embedded devices. I know the issue can be fixed by using Q_PROPERTY and notification signals, but I am trying to understand what might be going wrong in low-end embedded hardware. Debugging is not helping much here as it is not repeatedly reproducible. It seems like there is some sync issue with Q_INVOKABLE method execution time and QML creation in some low-end hardware. For example, if I want to show the version number of an application by invoking a C++ function like below: text: "Version:" + *backendCPP.getVersion()* Do you see any problem with the above line? Thanks & Regards, Nibedit On Thu, Jul 29, 2021 at 11:18 PM Alexander Dyagilev <alervd...@gmail.com> wrote: > *backendCPP.getStringData() is a method. You can't bind it. You should > use propery (Q_PROPERTY) and bind to it * > *instead. * > On 7/27/2021 6:50 PM, Nibedit Dey wrote: > > Dear All, > > I recently came across a strange issue related to QML binding. > The issue is not reproducible often which makes it difficult to find the > root cause. > > Sample QML code: > Case 1: *text : "Retrieved details"+ backendCPP.getStringData() > //Sometimes, the complete string is empty* > *Case 2: property string someString : backendCPP.getStringData()* > *text: **"Retrieved details:"+** someString // Displays **Retrieved details: > value remains empty* > > 99% time, the value is fetched and displayed properly in Text element. > Rarely, it remains empty. > Here backendCPP is a C++ instance exposed through context property and > an invokable method is used to fetch data. Notify signal is not used in > this case. > I believe during failure cases the data is not retrieved from backendCPP, > when binding happened due to delay in the invokable method. Is my > assumption correct? > Although we can handle the issue in multiple ways including using a NOTIFY > signal or using Qt.binding, I am curious if anyone has observed this issue. > Please share your inputs. > > Thanks & Regards, > Nibedit > > _______________________________________________ > Interest mailing > listInterest@qt-project.orghttps://lists.qt-project.org/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest