Issue
related post here
QTablewidget drop without creating new rows
but this has not been confirmed yet.
Is it duplicate?but I dare to ask...
I'm making QTableWidget
I want to install drag & drop Event.
But it has side-effect.
When this code is executed,
from PySide import QtGui
from PySide import QtCore
import sys
class CustomTableWidget(QtGui.QTableWidget):
def __init__(self,row=0,column=0,parent=None):
super(CustomTableWidget,self).__init__(parent=None)
self.setRowCount(row)
self.setColumnCount(column)
self.selection_start = False
self.setAcceptDrops(True)
self.setDragEnabled(True)
self.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
self.setDragDropOverwriteMode(False)
self.setDropIndicatorShown(True)
def main():
try:
QtGui.QApplication([])
except Exception as e:
print(e)
table = CustomTableWidget(10,10)
for i in range(10):
for k in range(10):
item = QtGui.QTableWidgetItem()
item.setText("{0},{1}".format(i,k))
table.setItem(i,k,item)
table.show()
sys.exit(QtGui.QApplication.exec_())
if __name__ == "__main__":
main()
The problem is when I drag an arbitrary item into other item,if I drop at the intersection of items,new row is inserted.
I want to change data only.I don't want to insert new row or column.
Do you have any idea?
Solution
I don't know why it is,but I could do it.
For doing it,
self.setAcceptDrops(True)
self.setDragEnabled(True)
To confine the only two attributes achieves my purpose.
Answered By - Haru
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.