QFile, QFileInfo

39 views
Skip to first unread message

Luigi Ferraris

unread,
Aug 11, 2017, 9:11:34 AM8/11/17
to QtContribs
Hi Pritpal,
I was working with QFile and QFileInfo objects and I see some problems.

a) about QFile
using
   oFile := QFile( QFile( "D:/temp/example.txt" ) )
   hb_trace( HB_TR_ALWAYS, " fileName=" + oFile:fileName() )
I get crash maybe because is not a valid Qt argument but HbQt seems accept; infact, reading QFile.qth I see

   HB_FUNC( QT_QFILE )
      if( hb_pcount() == 1 && hbqt_par_isDerivedFrom( 1, "QFILE" ) )
      {
         __HB_RETPTRGC__( new QFile( hbqt_par_QFile( 1 ) ) );
      }
  
but Qt handle this as parent (see QObject as argument). I think must be removed.

b) about QFileInfo
   b.1) oFileInfo := QFileInfo( "D:/temp/example.txt" )
   hb_trace( HB_TR_ALWAYS, " fileName=" + oFileInfo:fileName() + ; //==>fileName=
                           " path=" + oFileInfo:path() + ;         //==>path=
                           " filePath=" + oFileInfo:filePath() )   //==>filePath=

   b.2) oFileInfo := QFileInfo( QFile( "D:/temp/example.txt" ) )
   hb_trace( HB_TR_ALWAYS, " fileName=" + oFileInfo:fileName() + ; //==>fileName=
                           " path=" + oFileInfo:path() + ;         //==>path=
                           " filePath=" + oFileInfo:filePath() )   //==>filePath=

   b.3) oFileInfo := QFileInfo( QDir("D:/temp/"), "example.txt" )
   hb_trace( HB_TR_ALWAYS, " fileName=" + oFileInfo:fileName() + ; //==>fileName=example.txt
                           " path=" + oFileInfo:path() + ;         //==>path=D:/temp
                           " filePath=" + oFileInfo:filePath() )   //==>filePath=D:/temp/example.txt

   b.4) oFileInfo := QFileInfo()
   oFileInfo:setFile( "D:/temp/example.txt" )
   hb_trace( HB_TR_ALWAYS, " fileName=" + oFileInfo:fileName() + ; //==>fileName=example.txt
                           " path=" + oFileInfo:path() + ;         //==>path=D:/temp
                           " filePath=" + oFileInfo:filePath() )   //==>filePath=D:/temp/example.txt

   b.5) oFileInfo := QFileInfo()
   oFileInfo:setFile( QFile( "D:/temp/example.txt" ) )
   hb_trace( HB_TR_ALWAYS, " fileName=" + oFileInfo:fileName() + ; //==>fileName=example.txt
                           " path=" + oFileInfo:path() + ;         //==>path=D:/temp
                           " filePath=" + oFileInfo:filePath() )   //==>filePath=D:/temp/example.txt


The first two doesn't work. Why? It's a Qt problem? I'm doing some mistakes?

Anyway, I noticed a little difference (C++) between setFile(string)
   p->setFile( ( QString ) hb_parstr_utf8( 1, &pText01, NULL ) );
and QFileInfo constructor QFileInfo(string)
   pObj = new QFileInfo( hb_parstr_utf8( 1, &pText01, NULL ) );

perhaps is wrong? can be more good as
   pObj = new QFileInfo( ( QString ) hb_parstr_utf8( 1, &pText01, NULL ) );

On the other hand, HbQt always use second format to manage string as argument, so I don't know
why there is this problem. IF it's a HbQt problem.

Regards
Luigi Ferraris
Reply all
Reply to author
Forward
0 new messages