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. Qml + Qt Class communication
Qt 6.11 is out! See what's new in the release blog

Qml + Qt Class communication

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 3.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi!

    I have the follow code:

    //bike.qml
    @
    Bike
    {
    Component.onCompleted : getStuff()
    }
    @
    // Bike.h
    @
    class Bike: public QObject
    {
    Q_OBJECT
    public:
    Q_INVOKABLE void getStuff();
    }
    @
    // Bike.cpp
    @
    void Bike::getStuff()
    {
    // do something
    }
    @
    In main I registered the class...

    The problem is.. On runtime it gives me a error "no variable founded" pointing to "getStuff" on QML file...

    What i'm doing wrong?

    [Edit: Added @-tags for code formatting; mlong]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      You should have registered the class with an identifier somehow.

      In that case, you would use
      @
      Component.onCompleted: something.getStuff()
      @

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        But.. I want to use the function.. as i use the proprieties....

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          There's no "getStuff" invokable function or slot defined in your Bike class.
          /edit: I meant declared, obviously.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @chriadam : Ok... a small mistake... but that is not the problem... :-(

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Ok :-D

              Today, with a "fresh head" :) I resolved the problem!

              Problem: A wrong Copy & past ... provokes a qmlRegisterType bad writed!

              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