Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QStringListModel methods inherited from QAbstractListModel said to be private #127

Open
nicoddemus opened this issue Sep 8, 2015 · 2 comments

Comments

@nicoddemus
Copy link

Hi there!

First of all thanks for the excellent Qt4 bindings! 😄

I'm the author of the pytest-qt plugin for pytest, and I'm currently working on creating a Python version of ModelTest.

I'm having some trouble testing a QStringListModel instance because it doesn't seem to provide all the public methods it should as a QAbstractListModel subclass. For example, the docs for QAbstractListModel explicitly say:

The columnCount() function is implemented for interoperability with all kinds of views, but by default informs views that the model contains only one column.

But the snippet below:

def test_string_list_model():
    from PySide import QtCore, QtGui
    model = QtGui.QStringListModel()
    model.setStringList(['hello', 'world'])
    assert model.columnCount(QtCore.QModelIndex()) == 1

Fails with this error:

TypeError: columnCount(const QModelIndex & parent) const is a private method.

I see the same issue with parent() and hasChildren() methods.

The same snippet works fine for PyQt4 and PyQt5.

Is this a known issue? Is there any workaround?

Cheers,
🍻

@nicoddemus nicoddemus changed the title QStringListModel methods inherited from QAbstractListModel private QStringListModel methods inherited from QAbstractListModel said to be private Sep 8, 2015
@The-Compiler
Copy link
Member

Did you actually test this with PyQt4/PyQt5 or just assumed it worked because of my model tester code (which uses sip.cast to circumvent this)? Your snippet fails for me with TypeError: QAbstractListModel.columnCount() is a private method with PyQt4/PyQt5 as well. 😉

Also, those methods definitely are private in Qt, so I don't think PySide is to blame here - except for not having a sip.cast equivalent 😉

@nicoddemus
Copy link
Author

Sorry, you are correct, the snippet does fail in PyQt4 and 5 as well... I got mislead by the documentation, but indeed the C++ header explicitly mark those functions as private. :frown:

I agree this is not a bug but is there any workaround for that problem in Pride?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants