Frameworks/Epics/Splitting kdelibs/Common Solutions

Jump to: navigation, search


Replace KDebug by QDebug. Replace KWarning by QWarning.

the traces shouldn't be activated in release mode.

For example :

   kWarning(7041) << "warning message"

Can be replaced by :

   qWarning() << "warning message"


Replace KTemporaryFile by QTemporaryFile.

For example :

  tmpFile = new KTemporaryFile();

Can be replaced by :

  tmpFile = new QTemporaryFile();


Replace KStandardPaths by QStandardPath.

For example to replace findAllResources :

  const QStringList magicFiles = KGlobal::dirs()->findAllResources("xdgdata-mime", QLatin1String("magic"));

You have this solution :

  const QStringList magicFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,QLatin1String("mime/magic"));

Another example to replace locateLocal :

  const QString pathDefaultMimeType = KGlobal::dirs()->locateLocal("xdgdata-mime", defaultMimeType+QLatin1String(".xml"));

You have this solution :

  const QString pathDefaultMimeType = QStandardPaths::storageLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/") + defaultMimeType + QLatin1String(".xml");

Another example to replace findExe:

  const QString umd = KStandardDirs::findExe(QString::fromLatin1("update-mime-database"));

You have this solution :

  const QString umd = QStandardPaths::findExecutable(QString::fromLatin1("update-mime-database"));


Replace KComponentData and use a QString instead

For example :

   explicit KLockFile(const QString &file, const KComponentData &componentName = KGlobal::mainComponent());

Can be replaced by :

   explicit KLockFile(const QString &file, const QString &componentName = QString());


Work in progress. Not yet in Qt5 or libinqt5, so this dependency has no solution yet.


Work in progress. Not yet in Qt5 or libinqt5, so this dependency has no solution yet.

This page was last modified on 3 December 2011, at 20:09. Content is available under Creative Commons License SA 4.0 unless otherwise noted.