Reply
Thread Tools
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#1
I want to write a simple toggle for on off the nfc. AFAIK there is no such an app.

Now I am at hello world stage and I googled I need to do that via DBus(Dont know what is that and is that able to control nfc).
I have read this link on nokia and I still confuse.

I have school lab on iphone and android. Is there some method like "onCreate" or "viewDidAppear" on n9(Qt Quick or Qt Widget)? How can I call C++/C method via QML? I am so confuse. Is there some more "getting started" guide about development on harmattan? Thank You.
 
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#2
Any hints for starter?
 
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#3
Still in trouble. Personally want to refer git projects, however I can't found toggle application which has open source.

Also should I need to install harmattan platform sdk? Seem scratchbox no longer host by nokia, do I need scratchbox if I have a real n9 device?

Or should I go for qtsdk?

Thanks
 
jflatt's Avatar
Posts: 534 | Thanked: 723 times | Joined on Oct 2009
#4
This is a pretty good example:
http://harmattan-dev.nokia.com/docs/...sicplayer.html

It shows how to set up an application with a c++ entry point that loads a qml document. You probably want to create your own NFC handling class, based on QObject, and use that in the setContextProperty call. In that NFC class, your method will be marked with Q_INVOKABLE to be able to call that method from the qml.

You probably want to use qt-components to get your toggle button:
http://harmattan-dev.nokia.com/docs/...go-switch.html
 

The Following User Says Thank You to jflatt For This Useful Post:
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#5
Thank you very much.
But the toggle I mean is something like :Toggle PSM, Toggle BT, 2G3G and FlightMode in ovi store, not qt-components toggle
Anyway those example help a lot.
The qml seems differ from xml on android and storyboard/xib on ios.
 
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#6
I just found this: toggle availability
https://github.com/ajalkane/toggleavailability
toggle Telepathy availability on n9/50

and 2g3g
https://projects.developer.nokia.com/2g3g/browser

I can't build the project using QtSDK 1.2.1(simulator):
TelepathyQt4/AccountManager: No such file or directory

qemu:
Qemu finished with error: Exit code was 127.

Last edited by michaelmhk; 2013-03-09 at 12:06.
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#7
Originally Posted by michaelmhk View Post
Is there some method like "onCreate" or "viewDidAppear" on n9(Qt Quick or Qt Widget)?
In QML there is Component.onCompleted.

Originally Posted by michaelmhk View Post
How can I call C++/C method via QML?
There are two ways of doing this. Let's say you have a C++ class MyClass, with two methods, methodOne() and methodTwo(). You can either create an instance of MyClass in your main function and make it available via the QDeclarativeContext::setContextProperty() method:

Code:
#include <QDeclarativeView>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>

....

QDeclarativeView view;
QDeclarativeContext *context = view.engine()->rootContext();
context->setContextProperty("myClass", new MyClass);
or you can declare MyClass as a creatable type in QML and instantiate it in QML:

Code:
qmlRegisterType<MyClass>("com.myapplication.items",1,0,"MyClass");
The above declaration can be made in either the MyClass constructor, or simply in the main() function. You can then create instances of MyClass in QML:

Code:
import QtQuick 1.1

Item {
    id: root

    MyClass {
        id: myClass
    }

    Component.onCompleted: myClass.methodOne()
}
In either case, to be able to call the methods of MyClass from QML, you must either make them public slots, or make them public and use the Q_INVOKABLE macro:

Code:
public:
    Q_INVOKABLE void methodOne();

public slots:
    void methodTwo();
If the methods you wish to call are getters/setters, then a better option may be to use the Q_PROPERTY macro, which enables you to get/set a property declaratively:

Code:
....

    Q_PROPERTY(int myNumber READ myNumber WRITE setMyNumber)

public:
    inline int myNumber() const { return m_number; }
    inline void setMyNumber(int num) { m_number = num; }

private:
    int m_number;
If the Q_PROPERTY macro is used, there is no need to use the Q_INVOKABLE macro for the methods.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 

The Following 2 Users Say Thank You to marxian For This Useful Post:
jflatt's Avatar
Posts: 534 | Thanked: 723 times | Joined on Oct 2009
#8
Understood, toggle or switch is the GUI component, as seen here:
http://www.developer.nokia.com/Commu...20110930200022
I guess the first question should have been, will this have a GUI?

Last edited by jflatt; 2013-03-06 at 22:47.
 

The Following User Says Thank You to jflatt For This Useful Post:
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#9
Originally Posted by jflatt View Post
Understood, toggle or switch is the GUI component, as seen here:
http://www.developer.nokia.com/Commu...20110930200022
I guess the first question should have been, will this have a GUI?
The final goal should without ui.
But I think I should start with simple ui first.
Also having notification without ui seem a bit difficult for me.
 
Posts: 111 | Thanked: 62 times | Joined on Apr 2012 @ Hong Kong
#10
Originally Posted by michaelmhk View Post
I just found this: toggle availability
https://github.com/ajalkane/toggleavailability
toggle Telepathy availability on n9/50

I can't build the project using QtSDK 1.2.1(simulator):
TelepathyQt4/AccountManager: No such file or directory

qemu:
Qemu finished with error: Exit code was 127.
Qemu work finally, don't know why missing libjpeg62, I am using ubuntu 12.10 x64

Code:
michael@michaelmhk-PC:~/QtSDK/Madde/bin$ ./mad remote -r dfl61-harmattan_3.2012.07-1 poweron -fg
Starting QEMU runtime dfl61-harmattan_3.2012.07-1
Executing env LD_LIBRARY_PATH=/home/michael/QtSDK/Madde/tools/qemu_linux_2011-10-19_x86-64/lib  /home/michael/QtSDK/Madde/tools/qemu_linux_2011-10-19_x86-64/bin/run-qemu.sh  -M n00 -portrait -skin share/qemu/skin/glow/skin.xml -qmp tcp:localhost:7778,server,nowait -mtdblock arm-qemu-rm680-nand.qcow2 -sd arm-qemu-rm680-image.qcow2 -clock unix -serial stdio -net nic -net user,hostfwd=tcp:127.0.0.1:6666-:22,hostfwd=tcp:127.0.0.1:13219-:13219,hostfwd=tcp:127.0.0.1:14168-:14168
/home/michael/QtSDK/Madde/tools/qemu_linux_2011-10-19_x86-64/bin/qemu_linux_2011-10-19_x86-64: error while loading shared libraries: libjpeg.so.62: cannot open shared object file: No such file or directory
michael@michaelmhk-PC:~/QtSDK/Madde/bin$ sudo apt-get install libjpeg62
 

The Following User Says Thank You to michaelmhk For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 11:00.