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. [Solved] Using c++ class from QML
Forum Updated to NodeBB v4.3 + New Features

[Solved] Using c++ class from QML

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 2.3k 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.
  • A Offline
    A Offline
    aksex
    wrote on last edited by
    #1

    Hey,

    I have QML a project for Symbian devices. I planned to create functionalities and UI with QML but it seems that there is no QTcpSocket in QML? So I've been googling around to find how to use c++ functions from QML.

    So if I have a text field for example where the user writes something and presses send, how do I use the c++ function from QML? I'm able to import the class to QML and everything seems to work fine but when I build it I get next error:
    @
    module "Networking" is not installed
    import Networking 1.0
    ^@

    I have main.qml where I import Networking, then I also have Networking.cpp/hpp class.
    In main.cpp I have used: @qmlRegisterType<Networking>("Networking", 1, 0, "network");@

    I'm quite confused how I am supposed to do this. There are quite a few examples but most of them are the opposite, using qml UI from Qt c++ project. I just want a to simply call c++ class from qml, I'm not really sure if it is even possible? I read about creating a plugin that I need to import in QML project?

    Thank you.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      In the general case, this is not going to work. I'd recommend you create the business end of your application in C++, and only the UI in QML.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aksex
        wrote on last edited by
        #3

        Ok,

        thank you for the reply. I think I will first do it completely with c++ with a very simple GUI and if everything seems running ok I try to create more fancy UI with QML. I'm more familiar with c++ anyways :)

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kahon
          wrote on last edited by
          #4

          Could you write main.cpp complete file? Because depend the place where you write this line this maybe not work.

          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