Open phil65 opened 1 year ago
Makes sense to support that option (and backport the logic to our Python reimplementation), yep!
Relevant change: Use QAbstractItemModelTester or QFileSystemModel (Ie5d2e22f) · Gerrit Code Review
No other relevant changes in Qt so far:
df9d882d41 Port from container.count()/length() to size()
76b07b05f0 Doc: add missing "see also"
2f35653a30 Use QAbstractItemModelTester or QFileSystemModel
05fc3aef53 Use SPDX license identifiers
b6759ff81c QAbstractItemModelTester: Fix typos in debug output # <- Python reimplementation is here
I did some initial work on this:
but the tests fail:
====================================================== FAILURES ======================================================
__________________________________________ test_fetch_more_disabled[False] ___________________________________________
CALL ERROR: Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
File "/home/florian/proj/pytest-qt/tests/test_modeltest.py", line 316, in fetchMore
assert self._fetch_more_allowed
AssertionError: assert False
+ where False = <test_modeltest.FetchMoreModel object at 0x7f867950e7a0>._fetch_more_allowed
________________________________________________________________________________
Traceback (most recent call last):
File "/home/florian/proj/pytest-qt/tests/test_modeltest.py", line 316, in fetchMore
assert self._fetch_more_allowed
AssertionError: assert False
+ where False = <test_modeltest.FetchMoreModel object at 0x7f867950e7a0>._fetch_more_allowed
________________________________________________________________________________
------------------------------------------------ Captured stdout call ------------------------------------------------
modeltest: Using Qt C++ tester
and I believe this is Qt's fault:
useFetchMore
is only a property, it follows that it needs to be set after creating the model tester and passing a model to itnonDestructiveBasicTest
fetchMore()
, before we even had a chance to disable thatNot sure if I should report this as a Qt bug, or just adjust the test so it allows fetchMore
to be called exactly once...
Did you try setting the property in the constructor?
QAbstractItemModelTester(model, useFetchMore=False)
(With Qt for Python, all properties can be set via constructor)
That's just syntactic sugar for:
tester = QAbstractItemModelTester(model)
tester.setUseFetchMore(False)
so it shows the same problem as well.
Okay. Thanks for trying!
I´m running into a recursive loop when using the ModelTester with recursive tree models. QAbstractItemModelTester gained an option to not call fetchMore with Qt6.4. ( https://doc.qt.io/qt-6/qabstractitemmodeltester.html#setUseFetchMore ) Since the _qt_tester attribute of ModelTester is only set after calling ModelTester.check(), there is no way to use that option. Would be nice if that option could get added. Thank you!