@@ -36,10 +36,22 @@ def setData(self, index, value, role):
36
36
return False
37
37
38
38
def rowCount (self , index ):
39
- return len (self ._data )
39
+ # the index validity check approach addresses the qabstractitemmodel.cpp check:
40
+ # QtWarningMsg: FAIL! model->hasChildren(topIndex) () returned FALSE (qabstractitemmodeltester.cpp:366)
41
+ # See https://stackoverflow.com/a/50988188/2848172
42
+ if index .isValid ():
43
+ return 0
44
+ else :
45
+ return len (self ._data )
40
46
41
47
def columnCount (self , index ):
42
- return len (self ._data [0 ])
48
+ # the index validity check approach addresses the qabstractitemmodel.cpp check:
49
+ # QtWarningMsg: FAIL! model->hasChildren(topIndex) () returned FALSE (qabstractitemmodeltester.cpp:366)
50
+ # See https://stackoverflow.com/a/50988188/2848172
51
+ if index .isValid ():
52
+ return 0
53
+ else :
54
+ return len (self ._data [0 ])
43
55
44
56
def get_data (self ):
45
57
return self ._data
@@ -193,13 +205,18 @@ def headerData(self, section, orientation, role):
193
205
return self ._h_header [section ]
194
206
195
207
def flags (self , index ):
208
+ # Note: index validity checks in this block address qabstractitemmodeltester error:
209
+ # QtWarningMsg: FAIL! flags == Qt::ItemIsDropEnabled || flags == 0 () returned FALSE (qabstractitemmodeltester.cpp:329)
210
+
196
211
# column 0 (axis value range and default) is set
197
212
# to non-editable
198
- if index .column () == 0 :
213
+ if index .isValid () and index . column () == 0 :
199
214
return super ().flags (index ) | Qt .ItemIsSelectable
200
215
# column 1 (instance value) is set to editable
201
- else :
216
+ elif index . isValid () and index . column () == 1 :
202
217
return super ().flags (index ) | Qt .ItemIsEditable
218
+ else :
219
+ return super ().flags (index )
203
220
204
221
def load_font (self , font_model ):
205
222
ttfont = TTFont (font_model .fontpath )
0 commit comments