Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-51834

While searching 'qt.conf' in qlibraryinfo.cpp, the additional searching path obtained from enviroment variable "QTDIR" should be considered.

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.6.0 RC, 5.7.0 Alpha
    • Core: Other
    • None
    • all platforms

    Description

      <Qt_Source_Dir>/qtbase/src/corelib/global/qlibraryinfo.cpp,
      QSettings *QLibraryInfoPrivate::findConfiguration() :
      If default file path ":/qt/etc/qt.conf" dose not exist, the function try to search 'qt.conf' from application's dir path.
      This works perfectly in the release package of developer's application which contains all the libraries required by the application. But when the application is being developed, and the path of Qt libraries has been changed from where it is installed, the developing application WILL NOT locat ’qt.conf' correctly and CAN NOT run or be debugged.
      So I suggest to use enviroment variable 'QTDIR' to locate the path of 'qt.conf' and make one more time of searching for it after searching the application's dir path.
      This improvement makes Qt libraries can be copied or moved to anywhere we want and never require rebuilding or use 'qtpaths.exe' to change the path, all we need to do is just change the value of enviroment variable "QTDIR".
      The code in function "QSettings *QLibraryInfoPrivate::findConfiguration()" (begin at line 184):

      QDir pwd(QCoreApplication::applicationDirPath());
      qtconfig = pwd.filePath(QLatin1String("qt.conf"));
      if (QFile::exists(qtconfig))
      return new QSettings(qtconfig, QSettings::IniFormat);

      should be changed to :

      QDir pwd(QCoreApplication::applicationDirPath());
      qtconfig = pwd.filePath(QLatin1String("qt.conf"));
      bool qt_conf_found = false;
      if (!QFile::exists(qtconfig)) {
      QString qtdir = QString::fromLocal8bit(qgetenv("QTDIR"));
      if (!qtdir.isEmpty())

      Unknown macro: { qtconfig = QDir(qtdir + QLatin1String("/bin")); if (QFile}

      } qt_conf_found = true;
      if (qt_conf_found == true)
      return new QSettings(qtconfig, QSettings::IniFormat);

      Also, the function "QString QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)" should make a little change:
      The code (begin at line 446):

      #elif !defined(QT_NO_SETTINGS)
      if (!QLibraryInfoPrivate::configuration())
      #endif

      should be changed to :

      #elif !defined(QT_NO_SETTINGS)
      QSettings * pcfg;
      if (!(pcfg = QLibraryInfoPrivate::configuration()))
      #endif

      to save the configuration for latter usage.
      And the code (begin at line 566):

      baseDir = QCoreApplication::applicationDirPath();

      should be changed to:

      QFileInfo settingfile(pcfg->fileName());
      baseDir = settingfile.absolutePath();

      because in windows, the prefix path pointed to the executable's dir does not make Qt work properly while there is no Qt's binary libraries in executable's dir, and the path of file 'qt.conf' is a better choice.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            zydadan@sohu.com johnyork
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes