Registered Member
|
Thx for reading and possibly answering this post
I'm striving to open a dbus adaptor with qt5. I provide you with a working example. See below. The example program works, but I don't see any available adaptor with qdbusviewver. It should be 'org.kde.main' What's wrong ? ### CMakeLists.txt ### cmake_minimum_required(VERSION 2. project(dbus) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus) # change path here ! set(Q "/opt/Qt5.3.1/5.3/gcc_64/include/") include_directories(${Q}QtCore ${Q}DBus) set(SRC main.cpp) qt5_wrap_cpp(MOC main.h) qt5_generate_dbus_interface(main.h main.xml) qt5_add_dbus_adaptor(SRC1 main.xml main.h Main) add_executable(main ${SRC} ${SRC1} ${MOC}) target_link_libraries(main Qt5::Core Qt5::DBus) ### main.h ### #ifndef MAIN #define MAIN #include <QtDBus/QtDBus> class Main: public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.main") public: Main(QObject *parent); public slots: QString Test(); }; #endif ### main.cpp ### #include "main.h" #include <QCoreApplication> #include "mainadaptor.h" Main::Main(QObject *parent) : QObject(parent) { new MainAdaptor(this); QDBusConnection::sessionBus().registerObject("/Main", this); } QString Main::Test() { return "Ok"; } int main(int argc, char *argv[]) { QCoreApplication qapp(argc, argv); Main Main(&qapp); qapp.exec(); } ### thx again for your help |
Administrator
|
If you don't get a response here, you may wish to try asking on the KDE Devel mailing list, where someone might be able to answer your question. It can be emailed at kde-devel@kde.org. You could also try using the KDBusAddons framework.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
I did as you suggested and also subscribed to the relevant forum at qt-project.org, but I got nothing, not even a acknowledgement of the issue.
Thank you for your help |
Administrator
|
Could you please upload a tarball of your source code somewhere, and explain what exactly is failing?
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
Sure, you can get it from http://skylendar.kde.org/dbus.tar.bz2, then run cmake and make as usual. You should get an executable named main.
Run main. It doesn't display anything, but if you launch qdbusviewer, a dbus bus named org.kde.main, should be displayed. It is not the case. It works with kde4 but not with qt5/kf5. Is it a QDBusAdaptor bug somewhere, or a bug in my small program ? |
Administrator
|
So it compiles, but does not list on D-Bus? Have you tried looking into KDBus, which is provided by one of the Frameworks?
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
will try, but all the involved resources of my program use qt5, so it seems to be a qt5 problem. In addition, kf5 crashes on my opensuse box.
Why a dbus bus can only be seen by a kf5 app and not by the native and relevant tool designed for that, qdbusviewer ? thx anyway for the tip. |
Registered Member
|
Also tried the standard dbus-send command, but I got the same thing. Something seems wrong with QDBusAdaptor, which is a key class of the qt dbus stack. Weird weird
Does it exist a working example of QDBusAdaptor for qt5 ? The one provided with the qt5 doc doesn't work as swell. |
Administrator
|
That is extremely unusual - if the included Qt examples don't work then something is very wrong. Is qdbus (as provided with Qt 5) able to work as a client?
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
A year late -- but the reason this is not working is not a build issue. Need to also register the serviceName. New main with fixes follows.
|
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]