What I would like to do is taking input from a sql database and put all these datas in a QListWidget, but I don’t know how many of them there gonna be, I need also to know the id of which one was clicked when clicked.
Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if str is the label from your sql query and n is the id then:
create your items with:
Set the id with:
and add it to the widget:
Then when its clicked you will get the signal
connect this to a slot in your class and get the id back with
But this is also a good time to use QTableView and QSqlQueryModel.