Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simple QtDBus question
Forum Updated to NodeBB v4.3 + New Features

Simple QtDBus question

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benjamince
    wrote on last edited by
    #1

    Hi there,

    I'm trying to get some IPC going between a program called Mixxx (for DJing) and a separate application used to control Mixxx. I'm going to implement this via the DBus. I understand how the DBus works, but I'm having trouble connecting to it using Qt. I've been working with the DBus examples provided by Qt. In the chat example, there is this section of code in the main:

    [code]ChatMainWindow::ChatMainWindow()
    : m_nickname(QLatin1String("nickname"))
    {
    setupUi(this);

    // add our D-Bus interface and connect to D-Bus
    new ChatAdaptor(this);
    QDBusConnection::sessionBus().registerObject("/", this);

    com::trolltech::chat *iface;
    iface = new com::trolltech::chat(QString(), QString(), QDBusConnection::sessionBus(), this);
    //connect(iface, SIGNAL(message(QString,QString)), this, SLOT(messageSlot(QString,QString)));
    QDBusConnection::sessionBus().connect(QString(), QString(), "com.trolltech.chat", "message", this, SLOT(messageSlot(QString,QString)));
    connect(iface, SIGNAL(action(QString,QString)), this, SLOT(actionSlot(QString,QString)));

    }
    [/code]

    My question is that in the new ChatAdaptor(this) line, what would I use in the place of 'this' if I don't have any Qt GUI? I'm not that
    comfortable with programming yet so if anyone can answer this it would be great if as much detail as possible could be included, like what 'this' is
    in this context? Any help is very much appreciated.

    Thanks in advance!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      miroslav
      wrote on last edited by
      #2

      Well, the ChatAdaptor object simply gets a parent object, I suppose. In the case you have posted, it is the ChatMainWindow widget. It does not need to be a QWidget inherited class, QObject is enough. Note how the pointer returned by "new ChatAdaptor(this)" is never stored anywhere. This is because the object will be deleted when the parent is deleted.
      In a non-GUI application, you can define a class inheriting QObject, and create the ChatAdaptor object and the QDBusConnections in it's constructor the same way. The QDBus functionality does not depend on the parent being a widget.

      Mirko Boehm | mirko@kde.org | KDE e.V.
      FSFE Fellow
      Qt Certified Specialist

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved