Qt World Summit: Submit your Presentation

QT 4.7.4 SDK 1.1.3 error : QColor::setNamedColor: Unknown color name ’...’

  • i download the new version of SDK 1.1.3 and i tried to run an application that i write before (for the previous version of SDK), but then i get this error all the time:
    QColor::setNamedColor: Unknown color name 'true'
    QColor::setNamedColor: Unknown color name 'false'

    why is this error appear ? and how can i fix this?


  • Can you show code lines where does this errors happen?

  • it's a big project, and it did work fine with the SDK 1.1.2.
    i don't know how to show the code.

  • If you do double click on error line on Build Issues pane - Qt creator open line with error automatically.

  • but the error is not appear at the build time/ compile time, it's come at run time, when i run qml files.
    i tried to search in google what are the reasons forr this error , but find nothing...

  • Ahh, I see, Well...
    Do you anywhere in project has convertion from QColor to QVariant or vice versa?

  • no :(

  • The errors seem to suggest that you are using "true" and "false" as color names... those are indeed not valid color names.

    Looks like some boolean value is converted into a string to me. I'd recommend checking whatever you use to set the colors.

  • Hi,

    This is most likely due to some of the QML optimizations done for QtQuick 1.1 (in certain cases, when QML needs to convert from a string to a type, it will go through all it's available "string convertors" (including string->color) and do a trial conversion). The warning has been removed for 4.8.

    The extra warning shouldn't impact the actual results, but if you'd like to get rid of the messages I'd suggest looking for any instances where you use the strings 'true'/'false', and see if they can be converted to use true/false boolean values instead. (If you can find the exact code causing the issue there might be other workarounds as well)


  • Hello,

    i'm getting same warnings too as;

    QColor::setNamedColor: Unknown color name 'icons/settings2.png'

    What should i do, ignore them or not ?

  • In the case of "true" and "false", simply search your source for "true" and "false" (with the quotes) and remove the quotes.

    I had this happen with the following code:
    @PropertyAction { target: foo; property: "visible"; value: "true" }@

    The correct way is:
    @PropertyAction { target: foo; property: "visible"; value: true }@

    If you can't figure out where the error is coming from, place a breakpoint in QColor::setNamedColor(), at the point where the warning is printed. The backtrace will tell you in which .qml file this happens, as some of the internal variables used in the declarative engine reveal the URL.

  • Hey,

    I have a Button as like:
    ToolButton {
    enabled: false
    id: btn_settings
    caption: ""
    icon: "icons/settings2.png"
    this is the unique "icons/settings2.png" where i'm using it. What i must to do for fixing that kind of Warnings.

    Edit: Formatted code. please wrap code in @ tags; mlong

  • nightroad, this depends on how your ToolButton component looks, there is nothing wrong with the code you posted.

  • Hi nightroad,

    What's the property type for the icon property? I'm guessing variant, if you are getting this warning? If that is the case, changing the property type to string or url should fix the issue (assuming you are able to change the component definition).


Log in to reply