Is Qml Calendar component going crazy? -
before open bug qt project, i'd ask if i'm doing wrong or qml calendar going crazy.
it follows code can used test it:
import qtquick 2.5 import qtquick.window 2.0 import qtquick.controls 1.4 import qtquick.controls.styles 1.4 import qtquick.layouts 1.1 window { visible: true width: 1024 height: 768 columnlayout { anchors.fill: parent anchors.margins: 8 calendar { id: calendar layout.fillwidth: true layout.fillheight: true weeknumbersvisible: true selecteddate: new date("2015/01/01") framevisible: true focus: true onvisiblemonthchanged: visiblemonthchangedref.currdate = visibleyear+"/"+visiblemonth onvisibleyearchanged: visibleyearchangedref.currdate = visibleyear+"/"+visiblemonth } label { id: visiblemonthchangedref layout.fillwidth: true property string currdate: "" text: "onvisiblemonthchanged -> " + currdate component.oncompleted: font.pointsize = font.pointsize*2 } label { id: visibleyearchangedref layout.fillwidth: true property string currdate: "" text: "onvisibleyearchanged -> " + currdate component.oncompleted: font.pointsize = font.pointsize*2 } } }
easy going, start application , you'll see calendar couple of labels report information visiblemonth
, visibleyear
provided calendar
component. labels filled accordingly onvisibleyearchanged
, onvisiblemonthchanged
of calendar
. selected date 2015/01/01.
well, go of month towards 2014.
the onvisibleyearchanged
looks right while accessing visiblemonth
, visibleyear
properties of calendar
, while onvisiblemonthchanged
looks me living in far future.
now, try move on of month towards 2015.
again, while onvisibleyearchanged
still behaving right way, onvisiblemonthchanged
accessing calendar
component sitting in past.
you can go , forth on new year , function reacting signal onvisiblemonthchanged
never behave looks me invoked once internal properties have not been set yet.
that said, doing wrong , problem within code (of course, 1 above small example more complex project) or i've found bug in 'calendar` component , should proceed opening ticket qt project?
even though looks bit strange me asking modify component, being notified it's updated, find changes have been partially set (a kind of work in progress notification), that's it.
it seems error in expectations. :-)
once month
moves on or on year
(that is, december january , vice versa), calendar
component correctly updates property visiblemonth
, property visibleyear
.
anyway, no guarantees corresponding signals (onvisiblemonthchanged
, onvisibleyearchanged
) emitted once internal representation has been updated whole.
actually, former emitted when changes second property still pending, querying visibleyear
property in listener ends wrong year (or @ least, 1 not updated yet).
as example of solution, user of component can work around odd behavior attaching listener both signals, though suspect out there better solution waiting me.
i'll manage find alternative approach. thank of responses.
Comments
Post a Comment