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. Functions are not supported in a Qt Quick UI form
Forum Updated to NodeBB v4.3 + New Features

Functions are not supported in a Qt Quick UI form

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 4 Posters 12.4k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jstoezel
    wrote on 21 Oct 2016, 15:28 last edited by
    #1

    Hi:

    I have a simple Qt Quick application, slightly modified from the template generated by Creator 3.6 to integrate C++ access via a singleton object.

    I invoke C++ from QML to set the text of a button as follows:
    Button {
    id: button1
    text: data_provider.get("button_text")
    }

    This syntax gets underlined red in Creator, and I get the following error message when trying to open the qml file with design:
    "Cannot open this QML document because of an error in the QML file:
    Functions are not supported in a Qt Quick UI form. (M222)"

    Meanwhile, my application seems to run properly (i.e. the C++ function call works just fine and I can properly set the text of the button at run time). The error is very annoying as I basically cannot use Creator to work in the Design window.

    What is this due to? And how to fix it?

    I also updated to Creator 4.1 and it does the same as 3.6.

    Regards,
    JS

    1 Reply Last reply
    0
    • B Offline
      B Offline
      benlau
      Qt Champions 2016
      wrote on 22 Oct 2016, 10:52 last edited by benlau
      #2

      Qt Quick UI Form is supposed to be a QML file with only visible element. No business logic should be present.

      When you create a Qt Quick UI Form by Qt Creator. It will create two files.

      1. YourItemForm.ui.qml
      2. YourItem.qml <--- You should write the logic here.

      Example:

      YourItem.qml

      YourItemForm {
        button1 {
          text: data_provider.get("button_text")
        }
      }
      

      YourItemForm.ui.qml

      Item {
        property alias button1 : button1 
        Button {
          id: button1
        }
      }
      

      p.s You don't need to setup the alias by your self. You may use GUI to do so.

      http://doc.qt.io/qtcreator/images/qmldesigner-export-item.png

      http://doc.qt.io/qtcreator/creator-quick-ui-forms.html

      T _ 2 Replies Last reply 5 Feb 2020, 19:20
      7
      • B benlau
        22 Oct 2016, 10:52

        Qt Quick UI Form is supposed to be a QML file with only visible element. No business logic should be present.

        When you create a Qt Quick UI Form by Qt Creator. It will create two files.

        1. YourItemForm.ui.qml
        2. YourItem.qml <--- You should write the logic here.

        Example:

        YourItem.qml

        YourItemForm {
          button1 {
            text: data_provider.get("button_text")
          }
        }
        

        YourItemForm.ui.qml

        Item {
          property alias button1 : button1 
          Button {
            id: button1
          }
        }
        

        p.s You don't need to setup the alias by your self. You may use GUI to do so.

        http://doc.qt.io/qtcreator/images/qmldesigner-export-item.png

        http://doc.qt.io/qtcreator/creator-quick-ui-forms.html

        T Offline
        T Offline
        TMJJ001
        wrote on 5 Feb 2020, 19:20 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • B benlau
          22 Oct 2016, 10:52

          Qt Quick UI Form is supposed to be a QML file with only visible element. No business logic should be present.

          When you create a Qt Quick UI Form by Qt Creator. It will create two files.

          1. YourItemForm.ui.qml
          2. YourItem.qml <--- You should write the logic here.

          Example:

          YourItem.qml

          YourItemForm {
            button1 {
              text: data_provider.get("button_text")
            }
          }
          

          YourItemForm.ui.qml

          Item {
            property alias button1 : button1 
            Button {
              id: button1
            }
          }
          

          p.s You don't need to setup the alias by your self. You may use GUI to do so.

          http://doc.qt.io/qtcreator/images/qmldesigner-export-item.png

          http://doc.qt.io/qtcreator/creator-quick-ui-forms.html

          _ Offline
          _ Offline
          _Michel
          wrote on 25 May 2021, 20:43 last edited by
          #4

          @benlau
          Hi,
          I'm using Qt 5.15 and can't have your example working. I'm trying to use the onClicked signal handler of a button

          I have SomeForm.ui.qml:

          Item {
              property alias refresh: refreshBtn
          
              Button {
                  id: refreshBtn
                  // size, color, ...
              }
          }
          

          and in Some.qml:

          SomeForm {
              refresh.onClicked: console.log("foo")
          }
          

          NOTE: this does not work either:
          in Some.qml:

          SomeForm {
              refresh {
                  onClicked: console.log("foo")
              }
          }
          

          What am I doing wrong ?

          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