D-BUS and accessibility
After porting kdelibs to D-BUS and Thiago's blog entry about controlling a KDE application via D-BUS, I decided to give it a try. After a bit of playing, I came up with a solution that automatically exports a com.trolltech.AccessibleObject interface for every widget (see screenshot).
The command dbus :1.63 /Window1/CurrentValue com.trolltech.AccessibleObject.description (where :1.63 is the app's bus ID) returns the accessible description of that widget:
sending message: QDBusMessage(type=MethodCall, service=":1.63", path="/Window1/CurrentValue", interface="com.trolltech.AccessibleObject", name="description", signature="", contents=( ) )
got message: QDBusMessage(type=MethodReturn, service=":1.63", path="", interface="", name="", signature="", contents=(QString("The current value") ) )
All my code does is to wait for a widget's create event and attaches a QDBusAdaptor to the newly created widget. The neat thing is that D-BUS takes ownership of that adaptor, so whenever the widgets gets deleted, the D-BUS interface vanishes as well. The total code to export the accessible information is less than 100 lines of code. And the best thing: The code is readable. The accessible information can be accessed from any language without hassle, even from command line (I can imagine some pretty handy scripts emerging).
Subscribe to our newsletter
Try Qt 6.3 Now!
Download the latest release here: www.qt.io/download.
Qt 6 was created to be the productivity platform for the future, with next-gen 2D & 3D UX and limitless scalability.
Explore Qt World
Check our Qt demos and case studies in the virtual Qt World
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.
Näytä tämä julkaisu Instagramissa.
Want to build something for tomorrow, join #QtPeople today! We have loads of cool jobs you don't want to miss! http://qt.io/careers #builtwithQt #software #developers #coding #framework #tool #tooling #C++ #QML #engineers #sales #tech #technology #UI #UX #CX #Qt #Qtdev #global #openpositions #careers #job
Henkilön Qt (@theqtcompany) jakama julkaisu