[q, fsot] howto dbus

Michael Tansella michael-tansella at gmx.de
Sat May 23 18:40:40 CEST 2009

On Friday 22 May 2009 20:10:23 arne anka wrote:
> that's maybe rather ot, but since i need it to program _with_ qt _for_ the
> freerunner ...
> short'n'sweet: has anybody a clear and usable tutorial howto write dbus
> apps with qt, notably registering an app to dbus and recieve dbus
> signals/events?
> say, as a plausible scenario, i want to subscribe to dbus and receive
> information about incoming calls (the same stuff zhone receives) ar make a
> call -- how do i go about?
> the stuff i found so far is to complex and has to little hands-on examples
> to use already existing infrastructure -- i am rather the type that
> embarks from small examples upon larger quests, not from reading lengthy
> texts and code which creates complete apps inclusive gui and all.

here is a little DBus Gypsy example, I hope it helps. The correct methodes can 
be found with mdbus.


QDBusConnection GPSConnection = QDBusConnection::systemBus();
/// check connection
if (GPSConnection.isConnected())
qDebug() << "successfully connected to system bus \n";
qFatal("Failed to connect to session bus");
/// create a proxy object for method calls 
QString ServiceBusName = "org.freedesktop.Gypsy";
QString ObjectPath = "/org/freedesktop/Gypsy" ;
QString MethodPath = "";
GPSInterface = new QDBusInterface(	ServiceBusName,
									MethodPath, 	//method path = "" search recursive in all subfolders 			
												for the called method 
									QDBusConnection::systemBus() );
/// due to new frameworkd policies it is necessary to create interfaces with 
the right MethodPath to 
/// call functions (not necessary for connections/signals) 						

GPSRescourceInterface = new QDBusInterface( ServiceBusName,
										 QDBusConnection::systemBus() );
GPSDeviceInterface = new QDBusInterface( ServiceBusName,
										 QDBusConnection::systemBus() );
GPSOusagedInterface = new QDBusInterface( ServiceBusName,
										 QDBusConnection::systemBus() );

connect(GPSInterface, SIGNAL( FixStatusChanged(int) ),this, SLOT( 
handleFixStatusChanged(int) ) );

connect(GPSInterface, SIGNAL( TimeChanged(int) ),this, SLOT( 
handleTimeChanged(int) ) );

connect(GPSInterface, SIGNAL( PositionChanged(int,int,double,double,double) 
),this, SLOT( handlePositionChanged(int,int,double,double,double) ) );

connect(GPSInterface, SIGNAL( ConnectionStatusChanged(bool) ),this, SLOT( 
handleConnectionStatusChanged(bool) ) );

connect(GPSInterface, SIGNAL( CourseChanged(int,int,double,double,double) 
),this, SLOT( handleCourseChanged(int,int,double,double,double) ) );

connect(GPSInterface, SIGNAL( AccuracyChanged(int,double,double,double) 
),this, SLOT( handleAccuracyChanged(int,double,double,double) ) );

More information about the community mailing list