mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-21 06:45:32 -06:00
Support invoking signals on QObject.
This commit is contained in:
parent
32f58c8439
commit
c5c2d3e3e1
2 changed files with 21 additions and 1 deletions
|
|
@ -73,7 +73,7 @@ QSharedPointer<NetVariant> NetQObject::invokeMethod(QString methodName, QSharedP
|
|||
QMetaMethod method;
|
||||
for(int x = 0; x < _qObject->metaObject()->methodCount(); x++) {
|
||||
method = _qObject->metaObject()->method(x);
|
||||
if(method.methodType() == QMetaMethod::Slot || method.methodType() == QMetaMethod::Method) {
|
||||
if(method.methodType() == QMetaMethod::Slot || method.methodType() == QMetaMethod::Method || method.methodType() == QMetaMethod::Signal) {
|
||||
if(methodName.compare(method.name()) == 0) {
|
||||
// make sure number of parameters match
|
||||
if(method.parameterCount() == parameterCount) {
|
||||
|
|
|
|||
|
|
@ -605,6 +605,26 @@ namespace Qml.Net.Tests.Qml
|
|||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_invoke_signal()
|
||||
{
|
||||
AssertQObject(qObject =>
|
||||
{
|
||||
var raised = false;
|
||||
using (qObject.AttachSignal("testSignalInt", parameters =>
|
||||
{
|
||||
raised = true;
|
||||
parameters.Count.Should().Be(1);
|
||||
parameters[0].Should().Be(3);
|
||||
}))
|
||||
{
|
||||
qObject.InvokeMethod("testSignalInt", 3).Should().BeNull();
|
||||
}
|
||||
|
||||
raised.Should().BeTrue();
|
||||
});
|
||||
}
|
||||
|
||||
private void AssertValue(INetQObject qObject, string method, object value)
|
||||
{
|
||||
var raised = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue