I did what was you suggested. Nothing added empty row when I use Source code 1 ui->tableView->update(); and also if I add the same model, because the new model replaces the previous one, it also delete the insetRow command. If you have another idea ? Thanks.
Hi All, I have a little problem with my QtCode, perhaps u guys can help me to solve the problem and I'll very appreciate. In my code, I aim to put an empty code to the QTableView whereas the query is get from QSqlQueryModel. I tried with sqlQueryModel->insertRow(0);, but nothing happend in the table. Completely the code looks like this Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 sqlQueryModel->setQuery("SELECT * FROM x=a, y=b where b.ID = 0AND (b.anotherid = a.anotherid )",sqlDatabase)...
Quoted from "Manivannan_1984" Quoted query->exec(); What is the return value for this command? Is it return success? try this .. QSqlQuery *query = new QSqlQuery("databasename"); how if it returns false ?
Hi All, I have a problem when I'm coding. I aim to add/append another record to my QTableView without removing previous record showed. The code below used to be like that. Have you any solution for me? Thanks a lot. Source code 1 2 3 4 5 6 7 8 model->setTable("Users"); model->setSort(User_Id, Qt::AscendingOrder); model->setHeaderData(User_Name,Qt::Horizontal,tr("Username")); model->setHeaderData(User_FirstName, Qt::Horizontal, tr("First name")); model->setHeaderData(User_LastName, Qt::Horizontal...
Hi All, How can I show/view several field (actually 3 field; name, address, and office) in a QTableView from a different table (that is an entity of SQL) that I call it from current table and both related by ID. Thanks a lot.
Hi All, I've a problem when I aim to insert more then one record into my QTableView. I've coded it with: Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 QSqlTableModel* modelTable = new QSqlTableModel(this,sqlDatabase); QSqlRecord record = modelTable->record(); record.setValue(Name,QVariant(tr("John"))); record.setValue(Address,QVariant(tr("Jakarta"))); record.setValue(Job,QVariant(tr("Accountant"))); modelTable->insertRecord(1,record); record.setValue(Name,QVariant(tr("Kim"))); record.setValue(Add...
you should define the record variable as a record of a model first. Source code 1 2 3 4 5 QSqlRecord record = modelTable->record(); record.setValue(1,QVariant(tr("hello1"))); record.setValue(2,QVariant("hei")); //tr("hello2"))); record.setValue(3,QVariant(tr("hello3"))); modelTable->insertRecord(1,record);
Hi All, How can I show/view several field (actually 3 field; name, address, and office) in a QTableView from a different table (that is an entity of SQL) that I call it from current table and both related by ID. Thanks a lot.
Hi all, I'm new to Qt so bear with me if the answer to this question seems fairly simple and sorry for my English, it's not good enough. I have a Qt4 GUI Application that allows the user to select items using a QDialog and the items should be set checkable. However I still can't get the selectedItems when the items is checked after the Dialog accepted. I've read all the docs, but can't seem to figure out how to solve it. I hope my question is clear enough and any help will be greatly appreciated...