PDA

View Full Version : SQL Query + ListView



prophet0
19th December 2011, 19:07
if(db.open()){

QSqlDatabase db = QSqlDatabase::database("maindb");
QSqlQuery query(db);

query.exec("SELECT `Name` FROM `dictionarystrings` WHERE `LanguageID` = '1'");

while (query.next()){
QString nameString = query.value(0).toString();
QStandardItem* item = new QStandardItem(nameString);
item->setEditable(false);
item->setCheckable(false);
item->setSizeHint(QSize(345,42));

model->setItem(nameString, item);

}


}

unsure exactly how to display the contents of my query in a listview i have on the gui ui.view


sorry i have learned more about coding with QT when asking for help and searching forums than i have watching video tutorials

thanks for all your help !!

Lykurg
19th December 2011, 19:19
See QSqlQueryModel and use QListView::setModel(). And also try to read the documentation of Qt. It is really good and comes with a lot of examples.