我有我的应用程序的QML一部分需要知道我在什么状态,currentProfileChanged
功能有给我QSystemDeviceInfo::Profile
,我想转换为QVaraint
,这样的信号在QML可以理解的轮廓为0到7之间的数字,但是这个功能:的QObject连接QSystemDeviceInfo ::简介到的QVariant
QObject::connect(deviceInfo,
SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
rootObject,
SLOT(changePower(QVariant(QSystemDeviceInfo::Profile))));
给这个奇怪的错误:
[Qt Message] Object::connect: No such slot
QDeclarativeItem_QML_3::changePower(QVariant(QSystemDeviceInfo::Profile))
in C:/Users/Gerhard/QTProjects/Raker/main.cpp:142
我在做什么错在这里?
如果我试试这个:
QObject::connect(deviceInfo,
SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
rootObject,
SLOT(changePower(QVariant(QSystemDeviceInfo::Profile))));
它这样说:
[Qt Message] Object::connect: No such slot
QDeclarativeItem_QML_3::changePower(QSystemDeviceInfo::Profile)
in C:/Users/Gerhard/QTProjects/Raker/main.cpp:142
如果我改变任何或两者都只是它的QVariant也抱怨不兼容的论点。
谢谢,但我已尝试但是它母鸡抱怨:[Qt的信息]对象::连接:在C无这样槽QDeclarativeItem_QML_3 :: changePower(QSystemDeviceInfo ::配置文件):/用户/格哈德/ QTProjects/Raker/main.cpp:142 – Gerharddc 2012-01-29 09:44:01
如同Arnold Spence建议 – Neox 2012-01-29 09:53:40
那样,将您的槽声明从'changePower(QVariant(QSystemDeviceInfo :: Profile))'更改为'changePower(QSystemDeviceInfo :: Profile)'在qml中声明一个声明,它看起来像这样:function changePower(power)。所有看起来像这样的其他人都需要QVAriant,然后他们才能工作。 – Gerharddc 2012-01-29 10:03:57