我正在为 QGIS 使用 python 插件。我使用 psycopg2做了 python 到 postgres 的连接。我从数据库中检索表的查询是:
cursor = self.con.cursor()
cursor.execute("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")
records = cursor.fetchall()
记录变量包含所有表格。我的 .ui 表单上有一个 QTreeView 组件。如何将记录变量中的所有表显示到 QTreeView 中。我们应该使用 QAbstractItemModel。但不知道如何去做。