In my program i have,this page with two tables like this:
And everytime e checked one row, the row pass to the table above. What i want to know if is one way to relate the IdTeste with the checkbox because in the table above i will need the Id to make changes on a table in Postgresql. I dont know what part of the code i should post were, but this is the part when i insert the data on the second table:
`def preenchetabel(self):`
`con = psycopg2.connect()`
` cursor = con.cursor()
cursor.execute("""SELECT * FROM "Teste" """)
num_rows9= cursor.rowcount
num_columns9 = len(cursor.description)`
` cursor.execute("""SELECT
"Teste"."IdTeste",
"Teste"."DataEntrada",
"Teste"."Código de Barras",
"Teste"."Numero de serie",
"Categorias"."NomeCategoria",
"Marcas"."NomeMarca",
"Teste"."Modelo",
"Fornecedores"."NomeFornecedor",
"Estado"."NomeEstado",
"Projetos"."NomeProjeto",
"Teste"."Valor/Uni",
"Teste"."Quantidade",
"Teste"."DataSaida"
FROM "Teste"
JOIN "Categorias" ON "Teste"."Categoria" = "Categorias"."IdCategoria"
JOIN "Marcas" ON "Teste"."Marcasss" = "Marcas"."IdMarca"
JOIN "Fornecedores" ON "Teste"."Fornecedores" = "Fornecedores"."IdFornecedor"
JOIN "Estado" ON "Teste"."Estado" = "Estado"."IdEstado"
JOIN "Projetos" ON "Teste"."Projeto" = "Projetos"."IdProjeto";""")
dados = cursor.fetchall`
`for row in range(num_rows9):
for col in range(num_columns9):
item = QTableWidgetItem("")
self.tableLinhaNova.setItem(row, col, item)
self.tableLinhaNova.setRowCount(0)
self.tableLinhaNova.setColumnCount(12)
self.tableProdutossaida.setRowCount(num_rows9)`
`self.tableProdutossaida.setColumnCount(num_columns9)`
` self.tableProdutossaida.setHorizontalHeaderLabels(["CheckBox","IdTeste","Data de Entrada","Código de barras","Número de Série","Categoria","Marca","Descrição/Modelo","Fornecedor","Estado","Projeto","Valor/uni","Quantidade","DataSaida"])`
` for row_idx, row_data in enumerate(dados()):`
` checkbox = QCheckBox()
checkbox.setCheckState(Qt.Unchecked)
checkbox.stateChanged.connect(self.handleCheckbox)
self.tableProdutossaida.setCellWidget(row_idx, 0, checkbox)`
`
for col_idx, cell_value in enumerate(row_data):`
item = QTableWidgetItem(str(cell_value))
self.tableProdutossaida.setItem(row_idx, col_idx + 1, item)
for row_idx, row_data in enumerate(dados()):
col_idx_after_removal = 0
for col_idx, cell_value in enumerate(row_data):
if col_idx not in num_columns9:
# Criar um item para a célula
item = QTableWidgetItem(str(cell_value))
self.tableProdutossaida.setItem(row_idx, col_idx_after_removal, item)
col_idx_after_removal += 1 `
If relate the id whit a checkbox isn´t possible how can i hide the id from the user and the Id still be in the row