Git
Announcing QFacebook: Qt port of Facebook Graph API
by fred on Jun.22, 2010, under API, Facebook, Git, Qt
Hi, everyone. Sorry, but no coding examples for today (even though I haven’t posted anything in a while
).
Today, I’m announcing a new project open for development: QFacebook. It consists of a Qt port of the Facebook Graph API.
The interest in creating this project came from another one that we are currently working on at INDT. We needed to access and manage Facebook accounts, but we didn’t want to use the old rest API.
There are three non-C++ solutions available: the official Javascript SDK from Facebook, a PHP SDK and a Python SDK. Seeing the lack of a Qt port for this API we decided to make our own library.
The project is hosted at gitorious and the the URL is:
As of now, the project has two usage examples that you can start coding with. But we are still working on the documentation.
Anyone is welcome use it or even join our development effort.
Handling GraphicsView events – Part. 1
by fred on Nov.16, 2009, under Git, GraphicsView, Qt
Hi, everyone. It’s been while since I’ve posted something here.
To take out some of the dust from the blog
, I figured we could start with something simple like handling events on the GraphicsView framework.
It works like this: The view (QGraphicsView) receives events and passes them to the scene (QGraphicsScene). In order to pass these events to the scene, the view must first convert these units (pixel coordinates) into scene units (vertex coordinates). This conversion process is transparent, but you access these coordinates through convenience methods like mapFromScene and mapToScene. This also applies for the inverse path (passing events from the scene to the view).
Now, let’s say you want to capture mouse events. To do that, you have to reimplement the mousePressEvent and/or mouseReleaseEvent methods. Depending on your needs, they can be reimplemented from within the QGraphicsItem class (handling single items) or the QGraphicsScene class (handling the whole scene).
Here’s an example (I’ve used the class from the previous post as reference):
void CustomItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { qDebug() << "Mouse button clicked at position: " << event->pos(); } void CustomItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { qDebug() << "Mouse button released at position: " << event->pos(); }
Every time you click on the item, it will display a clicked message, and every time you release the mouse, it will display a released message. These methods are called whenever the desired event happens (Mouse presses, Mouse releases, Mouse moves, Key presses, Key releases, etc).
The QGraphicsSceneMouseEvent is the mouse event object. It’s a similar class to the QMouseEvent class, except that it only handles the QGraphicsView mouse events and not QWidget events.
There are also other handling methods like: mouseMoveEvent and mouseDoubleClickEvent for mouse events or keyPressEvent and keyReleaseEvent for keyboard events. For the keyboard ones, the item must be able to receive keyboard focus (QGraphicsItem::ItemIsFocusable flag set). You just need to reimplement them as in the code above.
And that’s it. I’ve also moved my previous examples (plus this one) to a repository at the Qt Gitorious.
The URL is http://gitorious.org/tech-blog/sources.
The example from this post is under the handling-events dir.