Apr-01-2025, 04:45 PM
Hello, guys...
Id like to know why my table shows double number of rows. First part with data and the second in blank.
The registers come from my database.
Id like to know why my table shows double number of rows. First part with data and the second in blank.
The registers come from my database.
def setupUi(self, pagMensalid,matr): dadosocio = ["",""] #Acrescent dadosocio = matr.split(",") #Acrescent pagMensalid.setObjectName("pagMensalid") pagMensalid.setWindowModality(QtCore.Qt.ApplicationModal) pagMensalid.resize(500, 500) pagMensalid.setMinimumSize(QtCore.QSize(500, 500)) pagMensalid.setMaximumSize(QtCore.QSize(500, 500)) self.centralwidget = QtWidgets.QWidget(pagMensalid) self.centralwidget.setObjectName("centralwidget") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(100, 10, 341, 41)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(16) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(40, 70, 81, 31)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(40, 120, 71, 31)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) self.label_3.setFont(font) self.label_3.setObjectName("label_3") self.txtmatr = QtWidgets.QTextEdit(self.centralwidget) self.txtmatr.setGeometry(QtCore.QRect(130, 70, 104, 31)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(12) self.txtmatr.setFont(font) self.txtmatr.setObjectName("txtmatr") self.txtnome = QtWidgets.QTextEdit(self.centralwidget) self.txtnome.setGeometry(QtCore.QRect(110, 120, 311, 31)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(12) self.txtnome.setFont(font) self.txtnome.setObjectName("txtnome") self.label_4 = QtWidgets.QLabel(self.centralwidget) self.label_4.setGeometry(QtCore.QRect(40, 180, 211, 16)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) font.setBold(True) font.setWeight(75) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.tblparc = QtWidgets.QTableWidget(self.centralwidget) self.tblparc.setGeometry(QtCore.QRect(40, 210, 441, 192)) self.tblparc.setStyleSheet("border-color: rgb(0, 0, 0);") self.tblparc.setObjectName("tblparc") self.tblparc.setColumnCount(3) self.tblparc.setRowCount(0) item = QtWidgets.QTableWidgetItem() font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(12) font.setBold(True) font.setWeight(75) item.setFont(font) item.setBackground(QtGui.QColor(255, 255, 0)) self.tblparc.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(12) font.setBold(True) font.setWeight(75) item.setFont(font) item.setBackground(QtGui.QColor(255, 255, 0)) self.tblparc.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(12) font.setBold(True) font.setWeight(75) item.setFont(font) item.setBackground(QtGui.QColor(255, 255, 0)) self.tblparc.setHorizontalHeaderItem(2, item) self.label_5 = QtWidgets.QLabel(self.centralwidget) self.label_5.setGeometry(QtCore.QRect(40, 440, 500, 600)) self.label_5.setMinimumSize(QtCore.QSize(500, 600)) self.label_5.setMaximumSize(QtCore.QSize(500, 600)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) font.setBold(False) font.setWeight(50) self.label_5.setFont(font) self.label_5.setObjectName("label_5") self.label_6 = QtWidgets.QLabel(self.centralwidget) self.label_6.setGeometry(QtCore.QRect(40, 420, 81, 20)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) font.setBold(True) font.setWeight(75) self.label_6.setFont(font) self.label_6.setObjectName("label_6") self.txttotal = QtWidgets.QTextEdit(self.centralwidget) self.txttotal.setGeometry(QtCore.QRect(120, 410, 104, 31)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(12) font.setBold(True) font.setWeight(75) self.txttotal.setFont(font) self.txttotal.setObjectName("txttotal") self.btnsair = QtWidgets.QPushButton(self.centralwidget) self.btnsair.setGeometry(QtCore.QRect(250, 460, 75, 23)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) font.setBold(True) font.setWeight(75) self.btnsair.setFont(font) self.btnsair.setStyleSheet("background-color: rgb(170, 170, 255);") self.btnsair.setObjectName("btnsair") self.btnquitar = QtWidgets.QPushButton(self.centralwidget) self.btnquitar.setGeometry(QtCore.QRect(150, 460, 75, 23)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(14) font.setBold(True) font.setWeight(75) self.btnquitar.setFont(font) self.btnquitar.setStyleSheet("background-color: rgb(170, 170, 255);") self.btnquitar.setObjectName("btnquitar") pagMensalid.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(pagMensalid) self.statusbar.setObjectName("statusbar") pagMensalid.setStatusBar(self.statusbar) self.txtmatr.setReadOnly(True) self.txtnome.setReadOnly(True) self.txttotal.setReadOnly(True) self.btnquitar.clicked.connect(lambda: self.consultarParcelas(dadosocio[0])) self.txtmatr.setText(dadosocio[0]) self.txtnome.setText(dadosocio[1]) self.bdAeje = sqlite3.connect('bdAeje.db') cursor = self.bdAeje.cursor() print("SELECT codpag,ref,valor FROM PAGAMENTO WHERE matr = '"+str(dadosocio[0])+"' AND quitado='Nao'") cursor.execute("SELECT codpag,ref,valor FROM PAGAMENTO WHERE matr='"+str(dadosocio[0])+"' AND quitado='Nao'") registros = cursor.fetchall() print("Total registros"+str(len(registros))) self.tblparc.clearContents() totlinhas = self.tblparc.setRowCount(len(registros)) self.bdAeje.close vltotal = 0 contador = 0 for row in range(len(registros)): #len(registros) campos = registros.__getitem__(row) self.tblparc.insertRow(row) #rowPosition self.tblparc.setItem(row, 0, QtWidgets.QTableWidgetItem(str(campos[1])))#rowPosition QtWidgets.QTableWidgetItem(str(campos[1])).setTextAlignment(4) self.tblparc.setItem(row, 1, QtWidgets.QTableWidgetItem(str(campos[2]))) QtWidgets.QTableWidgetItem(str(campos[2])).setTextAlignment(4) checkbox_item = QTableWidgetItem() checkbox_item.setFlags(checkbox_item.flags() | Qt.ItemIsUserCheckable) # Permitir que o item seja um checkbox checkbox_item.setCheckState(Qt.Unchecked) #Qt.Unchecked self.tblparc.setItem(row,2,checkbox_item) vltotal = vltotal + campos[2] contador = contador + 1 self.txttotal.setText("R$ "+str(vltotal)+",00") self.retranslateUi(pagMensalid) QtCore.QMetaObject.connectSlotsByName(pagMensalid)