我试图连接到阿莫克d总线信号StatusChange (参考:https://xmms2.org/wiki/MPRIS#StatusChange)。接口和结构是可以的,因为我可以连接到同一个接口中的简单信号CapsChange(int),并且可以通过GetStatus dbus方法获得状态,所以这个马歇尔结构是可以的:
struct AmarokStatus {
int st1;
int st2;
int st3;
int st4;
};
Q_DECLARE_METATYPE(AmarokStatus)
qDBusRegisterMetaType<AmarokStatus>();但打电话时:
mInf = new QDBusInterface("org.mpris.MediaPlayer2.amarok", "/Player",
"org.freedesktop.MediaPlayer", QDBusConnection::sessionBus(),this);
connect(mInf, SIGNAL(StatusChange(AmarokStatus)), this, SLOT(statusChanged(AmarokStatus)));
connect(mInf, SIGNAL(CapsChange(int)), this, SLOT(capsChange(int)));我收到消息:
对象:连接:没有这样的信号org::freedesktop::MediaPlayer::StatusChange(AmarokStatus)
我尝试过使用SIGNAL(StatusChange(struct))和SIGNAL(StatusChange(QDbusargument))和其他类型,但是使用相同的消息。
StatusChange的定义是:StatusChange(结构(Int32,Int32)),与dbus监视器相同.信号TrackChange(结构阵列)也存在同样的问题。因此,我肯定是在用connect()方法破坏一些东西。
发布于 2022-09-27 19:07:23
有两种选择:
或
if (!QDBusConnection::systemBus().connect("org.mpris.MediaPlayer2.amarok", "/Player", "org.freedesktop.MediaPlayer", "StatusChange", this, SLOT(statusChanged(AmarokStatus)))) {
qWarning() << "Failed to connect";
}https://stackoverflow.com/questions/20712546
复制相似问题