Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML Style error from QT's qml file.



  • I have a customized TextField and I am customizing this by using TextFieldStyle. Please see the below code snippet.

    In My UIStyles.qml****
    property Component textFieldStyle : TextFieldStyle {
    background: Rectangle {
    color: control.enabled ? control.activeColor
    : control.deactiveColor
    }
    }

    ***TextField.qml ***
    TextField {
    id: textField
    style:Style.textFieldStyle
    }

    When i run my application which uses this custom textFiled. I am getting following errors in my "Application Output" window

    Errors**
    file:///opt/Qt5.5.1/5.5/gcc/qml/QtQuick/Controls/Styles/Base/TextFieldStyle.qml:142: TypeError: Cannot read property of null
    file:///opt/Qt5.5.1/5.5/gcc/qml/QtQuick/Controls/Styles/Base/TextFieldStyle.qml:142: TypeError: Cannot read property of null
    file:///opt/Qt5.5.1/5.5/gcc/qml/QtQuick/Controls/Styles/Base/TextFieldStyle.qml:142: TypeError: Cannot read property of null
    file:///opt/Qt5.5.1/5.5/gcc/qml/QtQuick/Controls/Styles/Base/TextFieldStyle.qml:142: TypeError: Cannot read property of null

    The error is generating from Qt's QML file. Why this happening. ? is am doing anything wrong ? Anybody give me a solution to avoid this. ?



  • You are referencing "Style.textFieldStyle", where is "Style" defined?



  • @xargs1 : That's fine, I just provided a sample code snippet. Basically i have a qmldir file which has singletone module for UIStyles.qml ["singletone Style 1.0 UIStyles.qml"].

    Actually the styles are working fine, but the error is getting logged simple, that's my issue.


Log in to reply