my general idea is like this when I want to modify the value in my table I search for it first (box N01 in image), maybe it will give me only one value or 2.
in the case of only one value it will be easy to fix.
in case of 2 value my idea is when I click on box N2 (in image) it retrieve data (probably the id value, because it will make it easy).
and when I click on the modifier (box N 3 on the image) it show me the value in each lineEdit (that's an easy part)
KJHAM.jpg
so my problem is when I click on the table (on bok 2 in image) its take on data at all.
this is my code for the search part:
def show_mod_RDV(self):
rdv_search = self.lineEdit_7.text()
rdv_search_date = self.dateEdit_5.text()
conn = sqlite3.connect('rdv_database.db')
c = conn.cursor()
result_M = c.execute("SELECT * FROM rdv_data WHERE name LIKE ? AND date LIKE ? ", (rdv_search, rdv_search_date) ).fetchall()
print(result_M)
self.tableWidget_3.clearContents()
if result_M:
self.tableWidget_3.setRowCount(0)
self.tableWidget_3.insertRow(0)
for row , form in enumerate(result_M):
for colum, item in enumerate(form):
#colum +=1
row_position = self.tableWidget_3.rowCount()
self.tableWidget_3.insertRow(row_position)
def show_mod_RDV(self):
rdv_search = self.lineEdit_7.text()
rdv_search_date = self.dateEdit_5.text()
conn = sqlite3.connect('rdv_database.db')
c = conn.cursor()
result_M = c.execute("SELECT * FROM rdv_data WHERE name LIKE ? AND date LIKE ? ", (rdv_search, rdv_search_date) ).fetchall()
print(result_M)
self.tableWidget_3.clearContents()
if result_M:
self.tableWidget_3.setRowCount(0)
self.tableWidget_3.insertRow(0)
for row , form in enumerate(result_M):
for colum, item in enumerate(form):
self.tableWidget_3.setItem(row, colum, QTableWidgetItem(str(item)))
#colum +=1
row_position = self.tableWidget_3.rowCount()
self.tableWidget_3.insertRow(row_position)
To copy to clipboard, switch view to plain text mode
and for the part of retrieving data from table is:
def cell_was_clicked(self, row, column):
print("Row %d and Column %d was clicked" % (row, column))
id_tab = self.tableWidget_3.currentColumn()
id_tab_clic = self.tableWidget_3.currentRow()
print (f' id tab is {id_tab}')
print (f' id tab_cl is {id_tab_clic}')
def cell_was_clicked(self, row, column):
print("Row %d and Column %d was clicked" % (row, column))
id_tab = self.tableWidget_3.currentColumn()
id_tab_clic = self.tableWidget_3.currentRow()
print (f' id tab is {id_tab}')
print (f' id tab_cl is {id_tab_clic}')
To copy to clipboard, switch view to plain text mode
this code shows me the row and the column that I clicked, the current column and the current row, but it did not take any real value from table.
is there any way to take value from this table or is there another better way that will be very helpful
Bookmarks