Random "Invalid grouped property access" error
-
How are you assigning icon? Perhaps you have an undefined property somewhere. Post that code if you have it please.
But in the mean time, use something like this:
T.Button { Component.onCompleted: { // check properties here. Nothing should be undefined, unless it's supposed to be. //for each property, do something like : if (!this_property.isUndefined()) { assign value } //elegant pseudocode else { handle undefined value (avoid crash) } //more elegant pseudocode } }Let me know how this goes.
Cheers
-
@devDawg Thank you for your reply :)
Please checkout the completed minimal project to reproduce this issue:https://drive.google.com/file/d/1XCjSXlXu4SfulP_hwRVwkoDjejdComHV/view?usp=sharing
There's no other property access will raise this error, except for this revision tagged and grouped
iconproperty which is defined inQQuickAbstractButton.
TheComponent.onCompleted()solution is not very suitable for my requirement because it will override bindings created before component completed. -
@devDawg Thank you for your reply :)
Please checkout the completed minimal project to reproduce this issue:https://drive.google.com/file/d/1XCjSXlXu4SfulP_hwRVwkoDjejdComHV/view?usp=sharing
There's no other property access will raise this error, except for this revision tagged and grouped
iconproperty which is defined inQQuickAbstractButton.
TheComponent.onCompleted()solution is not very suitable for my requirement because it will override bindings created before component completed.Hi @GPBeta
I tried your example, it works without problems on my system (Win10, VS2017, Qt 5.11.0).
The "randomness" of the problem seems not reproducible here?My.Button { text: "My Button" onClicked: { console.debug("T.Button: " + icon.height + ", " + icon.width) } }gives:
qml: T.Button: 18, 18 qml: T.Button: 18, 18 qml: T.Button: 18, 18 ... qml: T.Button: 18, 18 qml: T.Button: 18, 18 qml: T.Button: 18, 18No warnings nor errors are produced.
-
Hi @Diracsbracket
The error occurs randomly only on startup, so please try to start it as much as possible, or just removeButton { text: "Qt Button" }and the program will never start here.
-
Hi @Diracsbracket
The error occurs randomly only on startup, so please try to start it as much as possible, or just removeButton { text: "Qt Button" }and the program will never start here.
@GPBeta
What isMyModule.Templates? You import it inimports\MyModule\Button.qmlbut it's defined nowhere. -
@GPBeta
What isMyModule.Templates? You import it inimports\MyModule\Button.qmlbut it's defined nowhere.@Diracsbracket
MyModule.Templatesis registered viaqmlRegisterModule("MyModule.Templates", 1, 0);
T.Buttonis registered viaqmlRegisterType<MyButtonTemplate>("MyModule.Templates", 1, 0, "Button");
They're both C++ codes inmain.cpp -
@Diracsbracket
MyModule.Templatesis registered viaqmlRegisterModule("MyModule.Templates", 1, 0);
T.Buttonis registered viaqmlRegisterType<MyButtonTemplate>("MyModule.Templates", 1, 0, "Button");
They're both C++ codes inmain.cpp@GPBeta
My bad... should have read your post more carefully...
I have never defined or even used templates before, so I will just watch and learn from this thread... -
@Diracsbracket
MyModule.Templatesis registered viaqmlRegisterModule("MyModule.Templates", 1, 0);
T.Buttonis registered viaqmlRegisterType<MyButtonTemplate>("MyModule.Templates", 1, 0, "Button");
They're both C++ codes inmain.cpp@GPBeta
By adding:import QtQuick.Templates 2.2to your
Button.qmltemplate file, it seems to work?import QtQuick 2.11 import QtQuick.Templates 2.2 import MyModule.Templates 1.0 as TApparently, without it, the required
QQuickIcontype fromqtquickcontrols2/src/quicktemplates2/qquickicon_p.hdoes not get registered, hence the errors you get?
-
@Diracsbracket Great! It works perfectly now!
The
QQuickIconis registered in theQtQuick.Templatesqml plug-in(qtquicktemplates2plugin.dll), while my C++ module only linked againstQt5QuickTemplates2.dll.So if we don't import that module explicitly, the icon property may be randomly registered later than the binding access.
I also tried to add
depends QtQuick.Templates 2.4in theqmldirbut with no luck.Whatever, I believe this is the best solution for me, thank you so much :)
-
@Diracsbracket Great! It works perfectly now!
The
QQuickIconis registered in theQtQuick.Templatesqml plug-in(qtquicktemplates2plugin.dll), while my C++ module only linked againstQt5QuickTemplates2.dll.So if we don't import that module explicitly, the icon property may be randomly registered later than the binding access.
I also tried to add
depends QtQuick.Templates 2.4in theqmldirbut with no luck.Whatever, I believe this is the best solution for me, thank you so much :)
@GPBeta
Thank you for the explanation. Now the randomness makes sense.
Btw. I just checked your webpage. It's quite awesome! -
@GPBeta
Thank you for the explanation. Now the randomness makes sense.
Btw. I just checked your webpage. It's quite awesome!@Diracsbracket lol, thank you :P