I have come across an issue that I am unable to resolve with regards to cell spanning on a table.<br>The issue... The cells span correctly, but there is a 'ghost' image left in the first cell as can be seen in the attached image.<br>
I have tried reversing the last 2 lines of the code below... tbl.setSpan and then tbl.setItem, but this did not help.<br>I appreciate any help on this.<br>-Eric<br><br>I am using PyQt 4.4 and Qt4.5<br><br>I created a form with a table on it with qtDesigner and then the following code ...<br>
<br><br>from PyQt4 import QtGui,QtCore<br><br>class subtracker_log(QtGui.QMainWindow):<br> def __init__(self, conn, parent = None): <br> #Load QT form created using designer<br> QtGui.QWidget.__init__(self) <br>
self.ui = Ui_trackerLog() #Name of the class created by pyQt from the qtDesigner (name of the form object: ex Ui_MainForm)<br> self.ui.setupUi(self) #Name of the function in class that sets up the ui<br>
self.testTable()<br><br> def testTable(self):<br> tbl = self.ui.tblTrackerLog<br> tbl.clear()<br> tbl.setRowCount(5)<br> hdrItems=['Per 0', 'Per 1', 'Per 2', 'Per 3', 'Per 4', 'Per 5', 'Per 6']<br>
tbl.setColumnCount(len(hdrItems))<br> <br> for i in range(len(hdrItems)):<br> headerItem = QtGui.QTableWidgetItem()<br> headerItem.setText(hdrItems[i])<br> tbl.setHorizontalHeaderItem(i,headerItem) <br>
<br> <br> cell = QtGui.QTableWidgetItem()<br> cell.setText('2,2')<br> cell.setTextAlignment(QtCore.Qt.AlignCenter)<br> tbl.setItem(2, 1, cell) <br> tbl.setSpan(2, 1, 0, 4)<br clear="all">
<br>-- <br>Eric Weick<br><br>Kofa High School<br>Teacher/Programmer<br>928.502.5585<br>