[email protected]
[Top] [All Lists]

Re: Why no QSqlQuery::value(QString&) method ?

Subject: Re: Why no QSqlQuery::value(QString&) method ?
From: Eric Methorst
Date: Fri, 14 Dec 2007 00:25:58 +0100
On Thursday 13 December 2007 18:22:41 Israel Brewster wrote:
> On Dec 13, 2007, at 3:51 AM, Bo Thorsen wrote:
> This is just one example of many that I have run into in trying to
> learn Qt where there is a function I need, but the closest thing I can
> find takes as an argument some piece of non-obvious data which I have
> to use other functions to find, ad infinitum. This is in spite of
> trying to do something that I would think would be fairly easy, such
> as the above example - see my messages to this list from early October
> Re: Efficient data retrieval. Having such convenience functions  would
> make it easier to find the methods I needed, not harder, even though
> the total number of available methods would be increased.
This is straight from the top part of the documentation:
==> To convert a field name into an index, use record().indexOf(),  <==
or example:
     QSqlQuery query("SELECT * FROM artist");
     int fieldNo = query.record().indexOf("country");
     while (query.next()) {
         QString country = query.value(fieldNo).toString();

If you read the documentation, this question will be answered within a few 
What I do find lacking is often a description of how the data model of the 
relationship between the classes. For example, it is never stated explicitely 
that a (preferably graphically) that a query contains records, and a record 
fields. You sort of have to figure this out for yourself. That would help one 
to know that if you can't find the functionality on the parent (query) you 
may have to look on the child (record).
Besides that, I find the QT documentation to be quite good. You just need to 
do a lot of reading, which I think anyone should. Somebody writes all that 
stuff: you should reward them by reading it ;-)
The overview pages in the assistant are quite usefull (this is where they give 
you an overview of a particular module, including a description of all the 
classes and what they do.)
And if all else fails, you can always use the ultimate two Manuals.

To unsubscribe - send a mail to [email protected] with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>