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. Help with error. Renamed icon failing upon being referenced.
Forum Updated to NodeBB v4.3 + New Features

Help with error. Renamed icon failing upon being referenced.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 225 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by Circuits
    #1

    I recently renamed an custom element. The element itself seems fairly straight forward and I do not believe it is causing the problem but here's it's definition:

    ThemedIcon
    {
      id: _helpIcon //renamed from "help"
      imageSource: "qrc:/Assets/Image/information.svg"
      height: 30
      checked: false
      width: height
      anchors
      {
        top: parent.top
        topMargin: 20
      }
    }
    

    somewhere on down the line this icon is being referenced:

    property bool helpEnabled: _helpIcon.checked && helpText !==  ""
    

    and it has the following comment next to it:
    //unexcusable abuse of qml tree with reusable specific component //yet you didn't fix it...

    So as I said I renamed the elment from "help" to "_helpIcon" and for some reason that broke the above property:

    ReferenceError: _helpIcon is not defined
    

    So I am new to QML and I have no idea what the comment is referring to and I don't see why changing this ThemedIcon's name would break anything. Any ideas what's happening here? Keep in mind the comment was not left by anyone in this office and the custom element was not built by anyone in this office. Otherwise I would just contact them and ask them lol

    J.HilkJ 1 Reply Last reply
    0
    • C Circuits

      I recently renamed an custom element. The element itself seems fairly straight forward and I do not believe it is causing the problem but here's it's definition:

      ThemedIcon
      {
        id: _helpIcon //renamed from "help"
        imageSource: "qrc:/Assets/Image/information.svg"
        height: 30
        checked: false
        width: height
        anchors
        {
          top: parent.top
          topMargin: 20
        }
      }
      

      somewhere on down the line this icon is being referenced:

      property bool helpEnabled: _helpIcon.checked && helpText !==  ""
      

      and it has the following comment next to it:
      //unexcusable abuse of qml tree with reusable specific component //yet you didn't fix it...

      So as I said I renamed the elment from "help" to "_helpIcon" and for some reason that broke the above property:

      ReferenceError: _helpIcon is not defined
      

      So I am new to QML and I have no idea what the comment is referring to and I don't see why changing this ThemedIcon's name would break anything. Any ideas what's happening here? Keep in mind the comment was not left by anyone in this office and the custom element was not built by anyone in this office. Otherwise I would just contact them and ask them lol

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Circuits

      you have to show some more of that file.

      Currently it should work, I explicitly checked it with _ as first character. But as a rule of thumb it would be good to start id's with a small letter and no capitals or special chars

      What version of Qt and QtQuick(import) do you use


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      C 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @Circuits

        you have to show some more of that file.

        Currently it should work, I explicitly checked it with _ as first character. But as a rule of thumb it would be good to start id's with a small letter and no capitals or special chars

        What version of Qt and QtQuick(import) do you use

        C Offline
        C Offline
        Circuits
        wrote on last edited by Circuits
        #3

        @J-Hilk Which file would you like to see more of? I figured out that the ThemedIcon is being created in a file which is holding another custom component:

        Component
        {
          id addNew
          
          NewFlow
          {
            id: _addNewFlow
            anchors.fill: parent
          {
        {
        

        which is then holding another compoenent of it's own:

        SettingsValueContainer
        {
        ...
        }
        

        which is the script housing the property. Here is what I also know. If I simply change the name back from _helpIcon to help it works again. This is a bit concerning because I have been starting all of my compoenent and element id's with an _

        EDIT: I think I figured out the problem but I am not sure what the convention is for how this should have been done. It would seem that there are multiple ThemedIcon's fighting over who owns this property or who this property is referencing. One exists within a file called ImplementSettingScreen:

        ThemedIcon
        {
          id: help
          imageSource: "qrc:/Assets/Images/information.svg"
          height: 30
          checked: false
          width: height
          anchors
          {
            top: parent.top
            topMargin: 20
          }
        }
        

        and again in the file i mentioned earlier called GuidanceSettingScreen:

        ThemedIcon
        {
          id: help
          imageSource: "qrc:/Assets/Images/information.svg"
          height: 30
          checked: false
          width: height
          anchors
          {
            right: parent.right
            top: parent.top
            rightMargin: 20
            topMargin: 20
          }
        }
        

        So when they are both named "help" then np but as soon as I change the name of one or the other (but not both) then they it's like the machine finally recognizes there was a conflict...

        how could this property possibly know which themedIcon called "help" it is suppose to be basing it's logic off of?

        EDIT 2

        There are many (many) more ThemedIcon's called "help". Now I am starting to understand the comment I think.

        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