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

Qt-interest Archive, June 2007
Wrong Libs or wrong Documentation?


Message 1 in thread

Hello all :)

i am new to qt, but not to c++ and i am just trying out some qt-classes
(qt3) with kdevelop (startet a qmake console application) on openSuse 10.2

i started with QDir, because its on my current interest...

reading the documentation under the URL
http://doc.trolltech.com/3.3/qdir.html i found the following code i
posted below.
the documentation says also that the return value of CDir::entryInfoList
shall be a Pointer to QFileInfoList.
But my libs provide a QFileInfoList - class itself as return value, not
a pointer to that. Searching the web i found examples, which tell the same.

i cant imagine that their should be two different distributions of qt
with different return values.
what is the error on that? where is my error located?

kind regards,
hagen

now follows the code example from trolltech, what is wrong on my system,
because entryInfoList's result is not a Pointer, but an Object
QFIleInfoList itself.

#include <stdio.h>
    #include <qdir.h <http://doc.trolltech.com/3.3/qdir-h.html>>

    int main( int argc, char **argv )
    {
        QDir d;
        d.setFilter <http://doc.trolltech.com/3.3/qdir.html#setFilter>( QDir::Files <http://doc.trolltech.com/3.3/qdir.html#FilterSpec-enum> | QDir::Hidden <http://doc.trolltech.com/3.3/qdir.html#FilterSpec-enum> | QDir::NoSymLinks <http://doc.trolltech.com/3.3/qdir.html#FilterSpec-enum> );
        d.setSorting <http://doc.trolltech.com/3.3/qdir.html#setSorting>( QDir::Size <http://doc.trolltech.com/3.3/qdir.html#SortSpec-enum> | QDir::Reversed <http://doc.trolltech.com/3.3/qdir.html#SortSpec-enum> );

        const QFileInfoList *list = d.entryInfoList <http://doc.trolltech.com/3.3/qdir.html#entryInfoList>();
        QFileInfoListIterator it( *list );
        QFileInfo <http://doc.trolltech.com/3.3/qfileinfo.html> *fi;

        printf( "     Bytes Filename\n" );
        while ( (fi = it.current()) != 0 ) {
            printf( "%10li %s\n", fi->size <http://doc.trolltech.com/3.3/qfileinfo.html#size>(), fi->fileName <http://doc.trolltech.com/3.3/qfileinfo.html#fileName>().latin1() );
            ++it;
        }
        return 0;
    }





--
 [ signature omitted ] 

Message 2 in thread

hello again

i think i should post a code example how it works at my system for a
better understanding of my previous question:

this is code, what could be compiled without errors on my system:

    QDir dir("/tmp");
    dir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden |
QDir::NoSymLinks );
   
    const QFileInfoList list = dir.entryInfoList();
    QListIterator<QFileInfo> it( list );
    QFileInfo info;


If i would change like in documentation to a pointer as the result, it
will give the following error:

	const QFileInfoList *list = d.entryInfoList <http://doc.trolltech.com/3.3/qdir.html#entryInfoList>();

Compiler said:

error: cannot convert âQFileInfoListâ to âconst QFileInfoList*â in initialization



Please excuse my posting of URLs in the previous mail, i just thought
that thunderbird would make plaintext without html-format and without
urls after copying from the web.

kind regards,
hagen




--
 [ signature omitted ] 

Message 3 in thread

Hagen,

I'm 90% sure that you're actually using Qt 4 instead of Qt 3. At the
beginning of your working code example, put
printf(qVersion());
And see what it says. The reason I say this is because the Qt 4
documentation (http://doc.trolltech.com/4.3/qdir.html) says that
entryInfoList returns a QFileInfoList (not a pointer). I tried your working
code, and that runs fine with my Qt 4 build but has compiler errors with my
Qt 3 build.

Tom

P.S. Sorry for replying to you off-list earlier, I still haven't gotten
Gmail to automatically reply to this list and occasionally I forget to
change the "To" field.

On 6/25/07, Hagen <qt@xxxxxxxxxxxx> wrote:
>
> hello again
>
> i think i should post a code example how it works at my system for a
> better understanding of my previous question:
>
> this is code, what could be compiled without errors on my system:
>
>     QDir dir("/tmp");
>     dir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden |
> QDir::NoSymLinks );
>
>     const QFileInfoList list = dir.entryInfoList();
>     QListIterator<QFileInfo> it( list );
>     QFileInfo info;
>
>
> If i would change like in documentation to a pointer as the result, it
> will give the following error:
>
>         const QFileInfoList *list = d.entryInfoList <
> http://doc.trolltech.com/3.3/qdir.html#entryInfoList>();
>
> Compiler said:
>
> error: cannot convert 'QFileInfoList' to 'const QFileInfoList*' in
> initialization
>
>
>
> Please excuse my posting of URLs in the previous mail, i just thought
> that thunderbird would make plaintext without html-format and without
> urls after copying from the web.
>
> kind regards,
> hagen
>
>
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

Message 4 in thread

Hi Tom

> I'm 90% sure that you're actually using Qt 4 instead of Qt 3. At the
> beginning of your working code example, put
> printf(qVersion());


You're right!
Its qt Version 4.2. Thank you very much Tom!

But, i cant still believe that they changed the result type from one
version to another within public classes! (i do so, but its heavy)
okay, for me it doesnt matter, because i dont have old qt-code.
but what is with all the other software in qt3? they cant be ported
simply to 4 because types changed in public class' methods... ?

so, before i start with qt in a bigger project: did i get it right that
there are such strong differences between qt3 and qt4 like described
above, also with types and interfaces of classes?

regards,
Hagen




--
 [ signature omitted ] 

Message 5 in thread

On Monday 25 June 2007 15:40, Hagen wrote:
> Hi Tom
>
> > I'm 90% sure that you're actually using Qt 4 instead of Qt 3. At the
> > beginning of your working code example, put
> > printf(qVersion());
>
> You're right!
> Its qt Version 4.2. Thank you very much Tom!
>
> But, i cant still believe that they changed the result type from one
> version to another within public classes! (i do so, but its heavy)
> okay, for me it doesnt matter, because i dont have old qt-code.
> but what is with all the other software in qt3? they cant be ported
> simply to 4 because types changed in public class' methods... ?
>
> so, before i start with qt in a bigger project: did i get it right that
> there are such strong differences between qt3 and qt4 like described
> above, also with types and interfaces of classes?

Qt4 is not even remotely source-compatible with Qt3.  A lot has changed.  
Check the porting information in the documentation.

--
 [ signature omitted ] 

Message 6 in thread

Hallo Chris


> Qt4 is not even remotely source-compatible with Qt3.  A lot has changed.  
> Check the porting information in the documentation.
>
>   

Thank you for this information!

Kind Regards
Hagen

--
 [ signature omitted ] 

Message 7 in thread

On 25.06.07 23:40:10, Hagen wrote:
> But, i cant still believe that they changed the result type from one
> version to another within public classes! (i do so, but its heavy)
> okay, for me it doesnt matter, because i dont have old qt-code.
> but what is with all the other software in qt3? they cant be ported
> simply to 4 because types changed in public class' methods... ?
> 
> so, before i start with qt in a bigger project: did i get it right that
> there are such strong differences between qt3 and qt4 like described
> above, also with types and interfaces of classes?

Yes, this is right. Qt4 is not Source and not Binary Compatible with
Qt3. In fact its not even possible to do some search/replace. 

But this is not really a problem. Qt4 was released about 2 years ago now
and Qt3 is still supported by TT. The lifetime of Qt4 is not just
another year or so.

Also Qt4 itself has very strict BC rules, which TT adhere's to (much
different that other open source libs, like for example openssl). So
such changes can only occur in a new Major version of Qt (like Qt5).

Last but not least: It is a good thing to completely throw away your
code and start afresh (well thats not really how Qt4 was developed I
think, but still). Because with time you'll find problems in your design
that are not fixable without breaking binary and source compatibility.
Thats why there are new major versions. Trying to keep full
compatibility for many years is just unrealistic.

Andreas

-- 
 [ signature omitted ]