Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用数据绑定填充QTableWidget_Python_Python 2.7_Python 3.x_Pyqt4 - Fatal编程技术网

Python 使用数据绑定填充QTableWidget

Python 使用数据绑定填充QTableWidget,python,python-2.7,python-3.x,pyqt4,Python,Python 2.7,Python 3.x,Pyqt4,我希望从Oracle数据库检索的数据用作QTablewidget的内容 因为我的数据库包含数千条记录,所以将它填充(使用循环)到QTableWidget需要更多的时间。是否有其他选项在不使用(for/while)循环的情况下填充它? 我想减少填充所需的时间 (1) 当前正在使用的代码: connection = self.DB_Connect() cursor = connection.cursor() cursor.execute(str(queryStr)) results = cursor

我希望从Oracle数据库检索的数据用作QTablewidget的内容

因为我的数据库包含数千条记录,所以将它填充(使用循环)到QTableWidget需要更多的时间。是否有其他选项在不使用(for/while)循环的情况下填充它? 我想减少填充所需的时间

(1) 当前正在使用的代码:

connection = self.DB_Connect()
cursor = connection.cursor()
cursor.execute(str(queryStr))
results = cursor.fetchall()

for row in range(0,len(results)):
    self.dlg.ui.tblWtGIS.insertRow(row)
    record = results[row]                 
    for column in range (0,len(record)):                        
        newitem = QTableWidgetItem(str(record[column]))
        self.dlg.ui.tblWtGIS.setItem(row,column,newitem)
(2) 我希望类似于下面提到的.NET代码

adap = New OleDbDataAdapter(query, dbcon)
adap.Fill(ds)
dgdb.DataSource = ds.Tables(0)
你能用api连接到你的数据库吗?。要使用数据绑定,需要使用QTableView+QSQLTableModel。