Home QDmx ql console Developer
Introduction Guide Admin tool Observer Qt API Java API Command Line Interface Download
This page give you examples on how to use the QDmx Library with Qt 4.5
See also API Documentation
To get a real example, you can have a look to the cli program source
To start, you simply require Qt 4.5, and qdmx client library.
Go to download page and take the appropriate binary version. You may also compile from sources (instructions on download page).
You will also require Qt 4.5 SDK
You have simply to add the following line in your .pro, it will add all required dependencies.
include(/path/to/qdmxlibrary/use-library.pri)
In your .cpp files, simply include "qdmxclient.h"
#include "qdmxclient.h"
Simple example : connect to server, and display universes list
The first step is to create an instance of QDmxClient, then you have to connect to server. There is multiple strategies :
Finally, you have to retreive universes list using fetchUniverses()
QDmxClient *client = new QDmxClient(); // Create a client if ( !client->connectAutoLocal() ) // Connect to local server (using default hostname and default port) { return; } if ( !client->fetchUniverses() ) // Fetch available universe list { return; } for (int i=0; j < client->universesCount(); i++) // Display all available universes { QDmxClientUniverse* univ= client->getUniverse(i); printf("%x\t%s\n",univ->getUid(),qPrintable(univ->getName())); // Note: QDmxClientUniverse provide more informations, see documentation for details } client->disconnectFromServer(); delete client;
You first have to get the universe using getUniverseByXXX() (you must have called fetchUniverses() before).
Then you have to start the universe with start(), and setup how many channels are active using setActiveChannelsCount().
From this point you can can send data using setChannels().
Once you have done, don't forget to call stop().
Example:
if ( !client->fetchUniverses() ) // Never forget to call this before trying to get some universe ! { return; } QDmxClientUniverse* univ = client->getUniverseByPermaId("dummy:0"); // Get sandbox univ->start(); // Start universe univ->setActiveChannelsCount(12); // Set how many channels are active quint8 data[12]; // Array of unsigned 8 bits integers (unsigned char) while ( /* ... some condition ... */ ) { // ... generate data ... univ->setChannels(0,12,data); // Send data } univ->stop(); // Stop universe
To be continued...
(c) Copyright 2006, 2009 Julien Etelain. All rights reserved. - Icons (c) Copyright Everaldo.com
Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.