[Solved] Using c++ class from QML
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?
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.
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 :)
Could you write main.cpp complete file? Because depend the place where you write this line this maybe not work.