Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtCore Settings does not support ini files located in resources
QtWS25 Last Chance

QtCore Settings does not support ini files located in resources

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
settingsqt6.5qml
2 Posts 1 Posters 297 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Richard Buchmann
    wrote on last edited by
    #1

    Hi,

    Qt.labs.settings (Qt5.15) supports read/write from/to files located in resources.
    After upgrading to Qt6.2, my legacy code still works.
    After upgrading to Qt6.5.1/Qt6.5.2, my application crashes in QQmlApplicationEngine::load function.
    QtCore Settings seems to 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!

    R 1 Reply Last reply
    0
    • R Richard Buchmann

      Hi,

      Qt.labs.settings (Qt5.15) supports read/write from/to files located in resources.
      After upgrading to Qt6.2, my legacy code still works.
      After upgrading to Qt6.5.1/Qt6.5.2, my application crashes in QQmlApplicationEngine::load function.
      QtCore Settings seems to 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!

      R Offline
      R Offline
      Richard Buchmann
      wrote on last edited by
      #2

      @Richard-Buchmann I guess I put this issue in the wrong place. I send a bug report there : https://bugreports.qt.io/browse/QTBUG-116681

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved