I loaded a Form with tableview have data (data loaded from MYSQL ), when a row on tableview is selected, data from each column will display on LineEdit ( Mã DL, Tên DL, Email, Địa chỉ, Điện thoại, Tiền nợ ) and also display on DateEdit ( Ngà y nháº*n ) but can not display on 2 Combobox ( Loại DL, Tên quáº*n ). See pic :

2.jpg


Combobox "Loại DL, Tên quáº*n" display " 1, Quan 1" is default Items, can not diaplay for tableview. These are code :

Qt Code:
  1. connect(ui.tableView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection &,const QItemSelection &)),this,SLOT(selectItem(const QItemSelection &,const QItemSelection &)));
  2. ui.tableView->selectRow(0);
  3.  
  4.  
  5. void QuanLyDaiLy::selectItem(QItemSelection selected,QItemSelection)
  6. {
  7. QSqlQueryModel *QModel;
  8. QModelIndexList items = selected.indexes();
  9. ui.txtMaDL->setText(QModel->data(items[0],Qt::DisplayRole).toString());
  10. ui.txtTenDL->setText(QModel->data(items[1],Qt::DisplayRole).toString());
  11. ui.txtEmail->setText(QModel->data(items[2],Qt::DisplayRole).toString());
  12. ui.txtDiaChi->setText(QModel->data(items[3],Qt::DisplayRole).toString());
  13.  
  14. QModelIndexList mySelection4 = ui.tableView->selectionModel()->selectedRows(4);
  15. QDate data4;
  16. foreach(QModelIndex selectedIndex4, mySelection4)
  17. data4 = selectedIndex4.data(0).toDate();
  18. ui.dtNgayNhan->setDate(data4);
  19.  
  20. ui.cbLoaiDL->itemText(QModel->data(items[5],Qt::DisplayRole).toInt());
  21. ui.cbTenQuan->setCurrentIndex(QModel->data(items[6],Qt::DisplayRole).toInt());
  22.  
  23. ui.txtDienThoai->setText(QModel->data(items[7],Qt::DisplayRole).toString());
  24. ui.txtTienNo->setText(QModel->data(items[8],Qt::DisplayRole).toString());
  25. }
To copy to clipboard, switch view to plain text mode 

ui.cbLoaiDL->itemText(...
ui.cbTenQuan->setCurrentIndex(..

itemText() and setCurrentIndex() functions are not work , which functions I can use ?

Thanks for help !