Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main.cpp:
- #include "myclass.h"
- #include <QtDeclarative>
- int main() {
- // before viewer is setup, add this:
- qmlRegisterType<MyClass>( "MyClass", 1, 0, "MyClass" );
- }
- myclass.h:
- class MyClass: public QObject {
- public:
- MyClass( QObject *parent );
- public slots:
- buttonPressed( QString msg ) {
- qDebug() << "Button was pressed:" << msg;
- emit blah( "test" );
- }
- signals:
- void blah( QString msg );
- }
- main.qml:
- import MyClass 1.0
- MyClass {
- id: localObject
- onBlah: console.log( "Received signal: " + msg );
- }
- Button {
- onClicked: localObject.buttonPressed( "something here" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement