QtQuasp应用程序和C++插槽绑定错误 我在后台使用C++学习QTQuice应用程序的过程中。我的计划是尽可能多地编写QQQueQML中的代码,但有一件事我找不到,所以我决定使用C++。基本上,我需要创建一个应用程序,为用户提供特定的小部件和一个按钮。单击按钮后,将创建并调用CLI命令。我可以使用JavaScript创建这个CLI命令,但是我没有找到如何执行这个命令的方法,所以我决定C++。 计划是在QML的按钮上登记一个信号,并将这个信号与C++中的一个时隙连接起来。我打开了QML文档,在那里我找到了几个有用的示例。我的测试应用程序代码包含两个源文件:
main.qml: main.cpp:QtQuasp应用程序和C++插槽绑定错误 我在后台使用C++学习QTQuice应用程序的过程中。我的计划是尽可能多地编写QQQueQML中的代码,但有一件事我找不到,所以我决定使用C++。基本上,我需要创建一个应用程序,为用户提供特定的小部件和一个按钮。单击按钮后,将创建并调用CLI命令。我可以使用JavaScript创建这个CLI命令,但是我没有找到如何执行这个命令的方法,所以我决定C++。 计划是在QML的按钮上登记一个信号,并将这个信号与C++中的一个时隙连接起来。我打开了QML文档,在那里我找到了几个有用的示例。我的测试应用程序代码包含两个源文件:,c++,signals,qml,slots,C++,Signals,Qml,Slots,main.qml: main.cpp: 也就是说,程序正在运行,但无法将cppSlot连接到我的按钮生成的信号上。我的问题是我遵循了QML手册,博客处理的是最复杂的问题,也就是说,我花了一天时间在谷歌上搜索,没有任何结果。您的代码无法编译: debug/main.o: In function `MyClass::MyClass()': /home/micurtis/dev/test/guitest/main.cpp:6: undefined reference to `vtable for My
也就是说,程序正在运行,但无法将cppSlot连接到我的按钮生成的信号上。我的问题是我遵循了QML手册,博客处理的是最复杂的问题,也就是说,我花了一天时间在谷歌上搜索,没有任何结果。您的代码无法编译:
debug/main.o: In function `MyClass::MyClass()':
/home/micurtis/dev/test/guitest/main.cpp:6: undefined reference to `vtable for MyClass'
如果我包括main.moc并删除对Logic.js的引用,当我单击Analyzuj时,它对我有效:
// ...
return app.exec();
}
#include "main.moc"
输出:
Starting /home/micurtis/dev/test/guitest/guitest...
QML debugging is enabled. Only use this in a safe environment.
Hello World - main!
Called the C++ slot with message: "Hello from QML"
/home/micurtis/dev/test/guitest/guitest exited with code 0
debug/main.o: In function `MyClass::MyClass()':
/home/micurtis/dev/test/guitest/main.cpp:6: undefined reference to `vtable for MyClass'
// ...
return app.exec();
}
#include "main.moc"
Starting /home/micurtis/dev/test/guitest/guitest...
QML debugging is enabled. Only use this in a safe environment.
Hello World - main!
Called the C++ slot with message: "Hello from QML"
/home/micurtis/dev/test/guitest/guitest exited with code 0