O
O
Oleg Seledets2018-04-24 19:28:49
SQL
Oleg Seledets, 2018-04-24 19:28:49

How to display SQL query in tableView?

Hello, I have a question.
it is necessary to display in the tableView the result of the request for a selection, from several text fields. It is a SQL query, for example ( ); now implemented in this way. ------ Questions pop up: 1) Is it possible to make it so that when you enter some text in the field, character by character, the table is updated. For example: in the text_pole_2 field, I enter the letter H, it updates the table, and displays all the records in this table, where the words in the current column begin with H. and so on? 2) Is it possible to make it so that by clicking on a line in the tableView all values ​​are placed in the lineEdit fields? 3) How can I increase the width of the application window when the button is clicked? "SELECT * FROM people1 WHERE name='"+pole2+"'"
model->setFilter("name = '"+pole2+"'");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Seledets, 2018-04-26
@oleja1ee7

The main problem is solved in this way:
QSqlQueryModel *setquery1 = new QSqlQueryModel;
setquery1->setQuery("SELECT * FROM people1 WHERE name LIKE '"+pole2+"%' AND id LIKE '"+pole1+"%'");
QTableView *tv = new QTableView(this);
tv->setModel(setquery1);
ui->tableView->setModel(setquery1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question