0

First of all sorry for my very poor English. I'll do my best to explain my problem.

I'm programming a CRUD for databases (with cx_Oracle) with a GUI made with PyQt5 organized by classes. I've already done the most part of my project. GUI implemented, delete operation already working. Problem is to implement update and create operation. I need to generate a line edit for each column of the database table I working on. What I did is

for x in range (size):
   self.d["getLine{}".format(x)] = QtWidgets.QLineEdit()

Where "d" is a dictionary In order to name each line edit different to work with them after. My problem is I can't get the text of each line edit when I click "send data" button.

Tried with:

self.sendButton.clicked.connect(lambda: self.getData(self.d["getLine{}".format(x)] for x in range(size)))

Where getData is a function that (at the moment) try to get each getLine.text() but didn't manage to work. I got this:

<generator object AddData.setupdata.<locals>.<lambda>.<locals>.<genexpr> at 0x000002263CE62AC0>

What does getData function have to do? Now (to test) just print(data) Data is what function receives from lambda call

So my question is if there are other way to generate multiple lines edit and then read all of them to store the data the user input.

I hope you can understand my problem and help me.

Edit: I finally found the solution. Hope help someone.

self.sendButton.clicked.connect(lambda: self.auxConteo(size))

And body of 'auxConteo' is:

def auxConteo(self, size):
        lines = list()
        datas = list()
        for x in range(size):
            lines.append(self.d['getLine{}'.format(x)])
        for c in range(len(lines)):
            datas.append(lines[c].text())
        print(datas)

So you can now read multiple QLineEdit at the same time ;)

0 Answers0