Important: Please read the Qt Code of Conduct -

QTableView with `from __feature__ import snake_case, true_property`

  • Hello,

    I'd like to use from __feature__ import snake_case, true_property directive. I started with my small QTableView example code.
    It's OK, but when I switch to true_property case, it stops working.

    As Qt for Python 6 released proposes, I simply replaced view.setModel(model) with view.model = model but then nothing happens and the view is empty. No error, just empty. I failed to find any docs for the true_property case. Do you have any suggestions? Thanks.

  • @petr-salajka

    This feature is not documented (it would be good to report it as a bug) but in the post you indicate is for Qt properties:

    With Qt 5.15.2, we introduced a new option called feature, enabling you to switch between camelCase and snake_case for most Qt APIs. With Qt 6.0, you can directly access Qt properties from your Python code, leaving aside the setters and getters, with the new true_property feature.

    and the model is not a Qt Property so you must use the set_model method: view.set_model(model)

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    QTableView has no "model" property hence you are replacing the setModel method with your model object. If anything you might be able to use "set_model" in place of setModel.

Log in to reply