Utilizing the Universal style in my QtQuick application, I am seeking to implement a ColorDialog for adjusting the accent color.
My current setup looks like this:
ColorDialog {
id: accChooser
title: "Please choose a color"
onAccepted: {
setGlobalAccentColor(accChooser.color)
}
}
*It is worth noting that directly setting Universal.accent=...
within a child item does not affect the parent component. Refer to this for more information.
Additionally, there is a function:
function setGlobalAccentColor(accentColor){
Universal.accent = accentColor
}
Although this function works when defined within the same QML file as accChooser
, when I attempt to define it in an external JS file (such as helpers.js
) and import it using:
import "helpers.js" as JSHelpers
and use it in this manner:
ColorDialog{
...
JSHelpers.setGlobalAccentColor(colorDialog.color)
...
}
it does not function as expected. No specific error or warning message is displayed in the output of the application.
Thank you.