[Solved] cannot set property of undefined
-
@if (component.status == Component.Ready)
{
var game = component.createObject(main_Window, {});
game.focus = true;
}@@if (component.status == Component.Ready)
var game = component.createObject(main_Window, {});
game.focus = true;
@
If construction "IF" returned TRUE. I did as you say, ERROR disappeared but whatever didn't work, *It seems that IF returned false. * and component are not ready.
Why in QT all is ok, but from EXE i have this problem. -
well I'm sorry to tell you this but the code is not the same.
@
if (component.status == Component.Ready)
var game = component.createObject(main_Window, {});
game.focus = true;
@@
if (component.status == Component.Ready)
{
var game = component.createObject(main_Window, {});
}
game.focus = true;
@
that is why game.focus = true produces and warning because "game" is undefined at that line... seems like nobody else is reading this thread but you tr it yourself if you don't believe me -
Hi petro2033,
Welcome to Devnet.
I suggest you experiment with if blocks and braces and debug in every possible place to see what your variables contain as values.
@
If (A)
B;
C;
@Is not the same as
@
If (A)
{ B;
C;
}
@PS: using capitals is generally considered as shouting to people. Please avoid it on the forum. Xander is just willingly to help you
-
-
hey of course it is the same if your "if" condition is evaluated to "true", but not if its "false".
in your case if the component is not ready there might be a problem in the pother QMl files (you didn't post it here so we can't help you with that):
@
var component = Qt.createComponent("Game.qml");
@
if that doesn't create a component either the QMl engine can't find the file or there is an error in the Game.qml, in any case you should see some error in the application console? -
[quote author="petro2033" date="1396232213"]ty all, but probles was that QtGraphicalEffects needs no dll, but needs QML file from Qt\Qt5.0.2\5.0.2\mingw47_32\qml\QtGraphicalEffects[/quote]
Does that mean that you figured out the problem? If so, please mark the thread as [Solved] by editing the title of you first post.)