onPaint event not triggered twice
-
Hallo,
I try to build my own spinBox. Now I draw my Up & Down Arrow buttons with Canvas which draw the arrows in the onPaint event.
Now the Problem
mainWindow.qml // Window where I would like to use my SpinBox { OwnSpinBox{ width: 100 height: 20 value: 20 //It works (Both of my Up&Down Arrows will draw with onPaint Component.onCompleted:{ value: 20 //Works not (Only one of both Arrows will draw with onPaint } } }
Component.onCompleted: value: 20
value: 20
It looks like that onPaint event works only once in ColumLayout. But only value will set in Component.onCompleted
value is a int which will checks in a cpp class if its valid. Is it valid da int will converted to a string and will write to the textInput as text.
My Cpp class inherits from QQuickItem.
Hope anybody can help me.
-
@itzwich1 said in onPaint event not triggered twice:
Component.onCompleted:{
value: 20 //Works not (Only one of both Arrows will draw with onPaint
}This syntax is incorrect. It should be:
Component.onCompleted:{ value = 20 }
-
@itzwich1 said in onPaint event not triggered twice:
Component.onCompleted:{
value: 20 //Works not (Only one of both Arrows will draw with onPaint
}This syntax is incorrect. It should be:
Component.onCompleted:{ value = 20 }
-
Assignment like this (with
=
) breaks bindings (with:
). So, if you rely on some property to set the value (likevalue: someOtherValue
), don't add override inonCompleted
. -
Assignment like this (with
=
) breaks bindings (with:
). So, if you rely on some property to set the value (likevalue: someOtherValue
), don't add override inonCompleted
. -
OK, now I begin to understand :-) Try forcing a repaint in your setter for
value
property (in C++). -
OK, now I begin to understand :-) Try forcing a repaint in your setter for
value
property (in C++). -
You can call
updatePaintNode(yourMainNode, nullptr);
if you have the main node stored somewhere. Alternatively, mark the node as dirty https://doc.qt.io/qt-5/qsgnode.html#markDirty -
You can call
updatePaintNode(yourMainNode, nullptr);
if you have the main node stored somewhere. Alternatively, mark the node as dirty https://doc.qt.io/qt-5/qsgnode.html#markDirty -
Verify if it's called or not with debugger or
qDebug
.Maybe paste the drawing code here, perhaps there's something wrong there?