Seite 1 von 1

sql + listview

Verfasst: 5. Mai 2005 14:42
von rodrigo
Hello,
I have a sql query and a ListViwe. I want to pu the values in my listview.
How can i make that?
I have no idea...


Thanks

void Form1::aselect()
{
QSqlQuery query;
query.exec("SELECT title, artist FROM sounds");
QMessageBox::information(this,
("Info"),
("Query ok"));


while(query.next()){
QString title = query.value(0).toString();
QString artist = query.value(1).toString();



}

}

Verfasst: 6. Mai 2005 19:48
von FlorianBecker
Please have a look to the QDataTable Class. http://doc.trolltech.com/3.3/qdatatable.html

Or you do this in the while loop:
QListViewItem *item = new QListView( listView );
item -> setText( 0, title );
item -> setText( 1, artist );

Maybe you want to read the example from Qt, there is something similar to your post.