Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, July 2004
Populating QListView with results from an SQL query.


Message 1 in thread

I have a simple SQL query

select fname from contactinfo;

and a QListView named searchresults.

I want to popluate the ListView with the results of the SQL query.

I tried 

searchresults->insertItem( query.value(0) );

but got a bunch of errors back.

Is there an quick way to do this?

Cheers,
Elliott


Message 2 in thread

Sorry, I made a mistake, it is a QListBox, not a QListView.

~e

----------
From: Elliott Perrin <eperrin@cseven.ca>
Reply-To: eperrin@cseven.ca
Date: Mon, 12 Jul 2004 14:44:19 -0400
To: <qt-interest@trolltech.com>
Subject: Populating QListView with results from an SQL query.

I have a simple SQL query

select fname from contactinfo;

and a QListView named searchresults.

I want to popluate the ListView with the results of the SQL query.

I tried 

searchresults->insertItem( query.value(0) );

but got a bunch of errors back.

Is there an quick way to do this?

Cheers,
Elliott

--
 [ signature omitted ] 

Message 3 in thread

Well, make sure you use toString() on your query.value(0).

On July 12, 2004 12:48 pm, Elliott Perrin wrote:
> Sorry, I made a mistake, it is a QListBox, not a QListView.
>
> ~e
>
> ----------
> From: Elliott Perrin <eperrin@cseven.ca>
> Reply-To: eperrin@cseven.ca
> Date: Mon, 12 Jul 2004 14:44:19 -0400
> To: <qt-interest@trolltech.com>
> Subject: Populating QListView with results from an SQL query.
>
> I have a simple SQL query
>
> select fname from contactinfo;
>
> and a QListView named searchresults.
>
> I want to popluate the ListView with the results of the SQL query.
>
> I tried
>
> searchresults->insertItem( query.value(0) );
>
> but got a bunch of errors back.
>
> Is there an quick way to do this?
>
> Cheers,
> Elliott
>
> --
> List archive and information: http://lists.trolltech.com/qt-interest/
>
> --
> List archive and information: http://lists.trolltech.com/qt-interest/

-- 
 [ signature omitted ] 

Message 4 in thread

On July 12, 2004 12:44 pm, Elliott Perrin wrote:
> I have a simple SQL query
>
> select fname from contactinfo;
>
> and a QListView named searchresults.
>
> I want to popluate the ListView with the results of the SQL query.
>
> I tried
>
> searchresults->insertItem( query.value(0) );
>
> but got a bunch of errors back.
>
> Is there an quick way to do this?

while (query.next()) {
	new QListViewItem(searchresults, query.value(0).toString());
}

-- 
 [ signature omitted ]