I show the data of a table (table1) in a QTableView. When the user selects a row, I want to read the data from this highlighted line. How can I do it easily?
For example will this read the whole data?
query.exec("SELECT * table1);
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.
I am assuming you are using a
QSqlTableModelwith your view. In this case you can usecurrentIndexin order to get the model index of the current item and then use therecordfunction of theQSqlTableModelin order to get the record corresponding to the index’s row:Then you can use the
fieldfunction ofQSqlRecordin order to get the values at the columns you want.