populate treelist help
into my project search button doesnt work.
run my app, add an employee, add some data with different dates, use search.
You notice that when insert data treelist populate data. When use search, treelist didnt populate:(
http://www.megaupload.com/?d=Y2OJCBYV
Any help?
5 replies
sql select
- QSqlQuery qry;
- qry.prepare("SELECT * FROM workmoneydata WHERE name=(:name) AND year>=(:fromYear) AND year<=(:toYear) "
- "AND month>=(:fromMonth) AND month<=(:toMonth) AND day>=(:fromDay) AND day<=(:toDay) ORDER BY id DESC LIMIT 15");
- qry.bindValue(":name", name);
- qry.bindValue(":fromYear", fromYear);
- qry.bindValue(":fromMonth", fromMonth);
- qry.bindValue(":fromDay", fromDay);
- qry.bindValue(":toYear", toYear);
- qry.bindValue(":toMonth", toMonth);
- qry.bindValue(":toDay", toDay);
- if (!qry.exec()){
- qFatal("Failed to populate search list");
- }
- return qry;
- }
Function calls select
- void MainWindow::searchData(){
- populateTreelist(employees.searchGetwmData(ui->comboBox->currentText(),ui->searchFromDateEdit->date().year(),
- ui->searchFromDateEdit->date().month(),ui->searchFromDateEdit->date().day(),
- ui->searchToDateEdit->date().year(),ui->searchToDateEdit->date().month(),
- ui->searchToDateEdit->date().day()));
- }
function populate treelist
- int i=0;
- QSImodel.clear();
- while (qry.next()){
- db_name=qry.value(0).toString();
- db_Payment=qry.value(8).toString();
- db_id=qry.value(9).toString();
- i++;
- }
- ui->treeView->setColumnHidden(0,true);
- ui->treeView->setColumnHidden(5,true);
- ui->treeView->setRootIsDecorated(false);
- ui->treeView->setModel(&QSImodel);
- }
treeview stay empty, dont even column headers added.
There is no error or warning.
QSImodel is a QStandardItemModel
one more link https://rapidshare.com/files/3781708727/wmtt.zip
You must log in to post a reply. Not a member yet? Register here!


