0

If you please can help me, I would appreciate it

I'm doing a query of sqlite3 and I want to show the result on a QListWidget

for row in c.execute("SELECT * FROM typem WHERE Type LIKE ?",('%'+'b'+'%',)):
     test = ''
     test += str(row[1])
     print test
     self.listWidget.addItems(test)

On the "print teste" is showing this

On the "print teste" is showing this

And on the "addItems" saves like this

And on the "addItems" saves like this

Can you please help me? Thanks

3
  • Change self.listWidget.addItems(test) to self.listWidget.addItem(test) Commented Sep 2, 2017 at 15:11
  • @eyllanesc Thanks once more! :) Commented Sep 2, 2017 at 15:12
  • Yes ofc :) In five minutes Commented Sep 2, 2017 at 15:17

1 Answer 1

1

When you use the addItems() method the QListWidget class assumes that you are passing an iterable so you get each element, and a string is an iterable, so you get that behavior. The solution in your case is to change addItems() to addItem().

Sign up to request clarification or add additional context in comments.

1 Comment

Hi mate, I'm sorry for bothering you again, it is possible to add you in some place to ask you a question? It's not to see any code of anything

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.