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

QtCore Settings does not support ini files located in resources

    XMLWordPrintable

Details

    • Linux/X11
    • 16002e56f (dev), f9e6ef9aa (6.6), ea3b6e4b5 (6.5)

    Description

      Hi,

      Qt.labs.settings (Qt5.15) supports read/write from/to files located in resources.
      After upgrading to Qt6.2/Qt6.4.3, my legacy code still works.
      After upgrading to Qt6.5.1/Qt6.5.2, my application crashes in QQmlApplicationEngine::load function.
      Both Qt.labs.settings and QtCore have the same behavior.

      I wrote an application sample to show you:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Window
      
      import QtCore  // for Settings (Qt >= 6.5)
      // import Qt.labs.settings 1.0  // for Settings (Qt < 6.5)
      
      Window {
          width: 640
          height: 480
          visible: true
      
          Rectangle {
              width: 100
              height: 100
              color: "red"
              border.color: "black"
              border.width: 5
              radius: 10
              Label {
                  id: label
                  anchors.centerIn: parent
                  text: "TBD"
      
                  Settings {
                      category: "test"
                      location: ":/test_settings.ini"  // NOK (Qt == 6.5)
                      // location: encodeURIComponent(":test_settings.ini")  // NOK (Qt == 6.5)
                      // location: "qrc://test_settings.ini"  // NOK (Qt == 6.5)
                      // no location                      // OK (Qt == 6.5)
                      // fileName: ":/test_settings.ini"  // OK (Qt < 6.5)                                     
                      property alias text: label.text
                  }
              }
          }
      }
      
      # ini file in resources
      [test]
      text=from resource
      
      # ini file in local storage
      [test]
      text=from local
      

      In this example, the application displays the wrong text. In Qt6.5, it always read from local storage. Never from resources.

      Thank you for your answer in advance!

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            rbuchmann Richard Buchmann
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes