'lightweight' QDir::isAbsolutePath replacement ?

Ralf Habacker ralf.habacker at freenet.de
Thu Mar 6 18:54:41 GMT 2008

Ralf Habacker schrieb:
> Hi,
> there are several places in the kde code which needs a check if a path 
> is absolute. On unix this is mainly done by using  
> QString::startsWith('/'), which does not work as expected on windows.
> The only static method Qt provides to handle this platform independent 
> is QDir::isAbsolutePath(). Unfortunally this method seems to be very 
> time expensive because it creates a temporary QDir instance.
One little correction: I fact QDir::isAbsolutePath() creates a QFileInfo 
instance instead of QDir but the problems still remains.

    static bool isRelativePath(const QString &path);
    inline static bool isAbsolutePath(const QString &path) { return 
!isRelativePath(path); }

bool QDir::isRelativePath(const QString &path)
    return QFileInfo(path).isRelative();


More information about the kde-core-devel mailing list