gpt4 book ai didi

python - 通过 QSqlTableModel 过滤连接到 SQLite 数据库的 QTableView 的内容

转载 作者:太空宇宙 更新时间:2023-11-03 17:58:55 25 4
gpt4 key购买 nike

如何过滤通过 QSqlTableModel 连接到 SQLite 数据库的 QTableView 的内容?

例如,如果数据库包含“名称”列,我只想显示名称为“Jack”的行?

最佳答案

您可以使用QSqlTableModel::setFilter() 。过滤将由模型完成, View 将自动更新以仅显示过滤后的项目。

The filter is a SQL WHERE clause without the keyword WHERE (for example, name='Josephine').

If the model is already populated with data from a database, the model re-selects it with the new filter. Otherwise, the filter will be applied the next time select() is called.

关于python - 通过 QSqlTableModel 过滤连接到 SQLite 数据库的 QTableView 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28035373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com