I have a qwidgettable that i want to set the specific column(i call it "Amount" column) to be in accounting format that if i type Eg. 1000 turns to 1,000.00 after I leave that cell and go over to another cell. I looked over the net but I couldn't find specific response to this query. Thank you so much in advance.
I actually tried this code but I don't know how to finish this:
self.table_data.setItemDelegateForColumn()
Edit:
Here is my code:
import sys
from PyQt5 import QtWidgets, QtCore
class Window(QtWidgets.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setGeometry(50,50,500,500)
self.setWindowTitle('PyQt Tuts')
self.table()
def table(self):
self.tableWidget = QtWidgets.QTableWidget()
self.tableWidget.setGeometry(QtCore.QRect(220, 100, 411, 392))
self.tableWidget.setColumnCount(3)
self.tableWidget.setRowCount(5)
self.tableWidget.show()
item = QtWidgets.QTableWidgetItem()
item.setText("Amount")
self.tableWidget.setHorizontalHeaderItem(1, item)
attr = ['Product1', 'Product2', 'Product3', 'Product4', 'Product5']
i = 0
for j in attr:
self.tableWidget.setItem(i, 0, QtWidgets.QTableWidgetItem(j))
i += 1
def run():
app = QtWidgets.QApplication(sys.argv)
w = Window()
sys.exit(app.exec_())
run()
This is what it looks like:
What I want to achieve is when I put 1000 in the amount in product 1. This will automatically become 1,000.00 after i leave that cell.
Not like this:
But like this: (this is just a snasphot in excel-format):



