sql + listview

Alles rund um die Programmierung mit Qt
Antworten
rodrigo

sql + listview

Beitrag 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();



}

}
FlorianBecker
Beiträge: 1213
Registriert: 2. Dezember 2004 10:54
Kontaktdaten:

Beitrag 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.
Antworten