Search code examples
qtqmlqt-quick

Style from singleton not updated during build


I am trying to style my application through a style singleton Style.qml that I register using qmlRegisterSingletonType. When I make changes to the singletons qml file these do not get updated when rebuildung the application.

The following behavior leads me to believe that this is a caching problem: When I add new values to the top of the style file all the old values get shifted accordingly. For example looking at the file given below, if I add another line to the fontsizes this shifting leads to any item with a value of backgroundColorHighlight being displayed with the color of backgroundColor inside the application. So the color is being replaced with the value of line it used to be in.

Where can I find the cache file (if that is the problem), that is responsible for this strange behavior and clear it manually?

Steps I have taken so far:

  • Cleaned the project through Qt Creator
  • Clened the project manually through deleting the build folder
  • Checked for and .qmlc files
  • Added QML_DISABLE_DISK_CACHE to .pro file
  • Ran qmake before rebuilding

Now I am all out of ideas. Is there any other place where Qt Creator / qmake can "hide" cache files?

Style.qml:

pragma Singleton
import QtQuick 2.8

QtObject {
    //basic fonts
    property int fontSizeSmall: 8
    property real fontSizeMedium: 10
    property real fontSizeLarge: 14
    property string primaryFontColor: "#eeeeee"

    //backgrounds
    property string backgroundColorTransparent: "#4a4a4a88"
    property string backgroundColor: "#4a4a4a"
    property string backgroundHighlight: "#9a9a9a"
    property string backgroundColorLight: "#7a7a7a"

    property string dragTileBackgroundColor: "#5a5a5a"
    property string titleBarColor: "#3a3a3a"

    property color borderDarkColor: "#3a3a3a"

    property string mapMarkerFavorite: "#00ff00";
    property string mapMarker: "#ff3333";
    property string mapMarkerHighlight: "#ff8888";

    property string miniMapFillColor: "#ffffff"
    property string miniMapBorderColor: "#ffffff"
    property real miniMapBorderWidth: 1
    property real particleMiniMapOpacity: 0.5

    property int listElementHeight: 30
}

Solution

  • Assuming windows, the cache should be in:

    users\yourUser\AppData\Local\yourApp\cache\qmlcache.

    There is a known bug, which I actually discovered, disabling the caching via qputenv("QML_DISABLE_DISK_CACHE", "1"); in main.cpp before you instantiate the QML engine will deal with a caching problem.