[Kde-bindings] Using Signals/Slots with String argument

Mat Arge argemat1010 at gmail.com
Tue Oct 29 13:14:46 UTC 2013


On Tuesday 29. October 2013 05:51:24 Dimitar Dobrev wrote:
>     You can use QtCoreApplication.Invoke. 

Damn, how could I miss that. Thanks a lot, that works.

cheers
Mat

> 
> 
> 
> On Tuesday, October 29, 2013 2:46 PM, Mat Arge <argemat1010 at gmail.com>
> wrote:
> 
> What I acutally want to achieve, is to change the UI from a different
> thread. According to the www, executing code in the UI thread can either be
> achieved via QMetaObject.InvokeMethod (see my other message to the list
> today) or via a signal/slot combination and so far I haven't managed to
> make either of them work in Qyoto.
> 
> cheers
> Mat
> 
> On Tuesday 29. October 2013 05:42:01 Dimitar Dobrev wrote:
> >     Hello, Mat,
> >
> >     I don't know if adding slots as string has ever worked (it's not me
> >who>
> > authored that part), I've never tried it. But let me ask you, why do you
> > need it? Why don't you simply use the events that wrap signals? In your
> >
> > case that would be:
> >        dialogB1.Clicked += OnDialogIntClicked;
> >
> >
> >     About custom signals, it's analogous: I haven't tried them (and
> >
> > therefore I don't know if they've ever worked) but you can simply use
> > Mono/.NET events instead.
> >
> >     Regards,
> >     Dimitar
> >
> > On Tuesday, October 29, 2013 2:32 PM, Mat Arge <argemat1010 at gmail.com>
> > wrote:
> > 
> > Hy!
> > 
> > I am unable to use signals/slots which use String as an argument. I
> > created
> > the code below to watch the value of a QInputDialog, If I set its
> > InputMode
> > to IntINput, everything works fine. But if I use the TextInput InputMode I
> > get the error message
> > QSignalSpy: No such signal: 'textValueChanged(string)'
> > 
> > Even worse, if I try to define my own signal MySignal which uses a string
> > argument, once I emit it I first get the error
> > 
> > Cannot handle 'string' as slot argument
> > 
> > promptly followed by a stacktrace, followed by a native stacktrace:
> >
> > Stacktrace:
> >   at (wrapper managed-to-native) QtCore.SignalInvocation.SignalEmit
> >
> > (string,string,intptr,intptr,int) <0xffffffff>
> >
> >   at QtCore.SignalInvocation.Invoke
> >
> > (System.Runtime.Remoting.Messaging.IMessage) <0x002af>
> >
> >   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
> >
> > (System.Runtime.Remoting.Proxies.RealProxy,System.Runtime.Remoting.Messagi
> > ng .IMessage,System.Exception&,object[]&) <0x003e3>
> >
> >   at (wrapper runtime-invoke)
> >
> > <Module>.runtime_invoke_object_object_object_Exception&_object[]&
> > (object,intptr,intptr,intptr) <0xffffffff>
> >
> >   at (wrapper managed-to-native)
> >
> > object.__icall_wrapper_mono_remoting_wrapper (intptr,intptr) <0xffffffff>
> >
> >   at (wrapper remoting-invoke) IMySignals.MySignal (string) <0xffffffff>
> >   at Dialog.<Dialog>m__1 () <0x000d2>
> >   at (wrapper runtime-invoke) object.runtime_invoke_void__this__
> >
> > (object,intptr,intptr,intptr) <0xffffffff>
> >
> >   at (wrapper managed-to-native)
> >System.Reflection.MonoMethod.InternalInvoke>
> > (System.Reflection.MonoMethod,object,object[],System.Exception&)
> > <0xffffffff> at System.Reflection.MonoMethod.Invoke
> > (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],S
> > ys tem.Globalization.CultureInfo) <0x0013f>
> >
> >   at System.Reflection.MethodBase.Invoke (object,object[]) <0x00022>
> >   at System.Delegate.DynamicInvokeImpl (object[]) <0x001bf>
> >   at System.MulticastDelegate.DynamicInvokeImpl (object[]) <0x00033>
> >   at System.Delegate.DynamicInvoke (object[]) <0x00016>
> >   at QtCore.SmokeInvocation.InvokeDelegate (System.Delegate,intptr)
> >
> > <0x000bf> at (wrapper native-to-managed)
> > QtCore.SmokeInvocation.InvokeDelegate (System.Delegate,intptr)
> > <0xffffffff>
> >
> >   at (wrapper managed-to-native) QtCore.SmokeInvocation.CallSmokeMethod
> >
> > (intptr,int,intptr,intptr,int,intptr) <0xffffffff>
> >
> >   at QtCore.SmokeInvocation.Invoke
> >(string,string,System.Type,bool,object[])>
> > <0x00277>
> >
> >   at QtGui.QApplication.Exec () <0x00047>
> >   at Dialog.Main (string[]) <0x00047>
> >   at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object
> >
> > (object,intptr,intptr,intptr) <0xffffffff>
> >
> > Native stacktrace:
> >         mono() [0x80e903d]
> >         linux-gate.so.1(__kernel_rt_sigreturn+0) [0xb772b410]
> >
> > ...
> > 
> > Here is my sample code:
> > 
> > using System;
> > using QtCore;
> > using QtGui;
> > 
> > public class Dialog : QWidget
> > {
> >
> >   int width = 250;
> >   int height = 200;
> >
> >
> >   public Dialog()
> >   {
> >     WindowTitle = "Input test";
> >
> >     Resize(width, height);
> >
> >     var vbox = new QVBoxLayout(this);
> >     QPushButton quit = new QPushButton("Quit");
> >     Connect(quit, SIGNAL("clicked()"), () => QCoreApplication.Quit());
> >     vbox.AddWidget(quit);
> >   
> >     QPushButton dialogB1 = new QPushButton("Dialog Int");
> >     Connect(dialogB1, SIGNAL("clicked()"), this,
> >
> > SLOT("OnDialogIntClicked()"));
> >
> >     vbox.AddWidget(dialogB1);
> >
> >     QPushButton dialogB2 = new QPushButton("Dialog Text");
> >     Connect(dialogB2, SIGNAL("clicked()"), this,
> >
> > SLOT("OnDialogTextClicked()"));
> >
> >     vbox.AddWidget(dialogB2);
> > 
> >     QPushButton mySig = new QPushButton("MySignal");
> >     Connect(mySig, SIGNAL("clicked()"), () => {Emit.MySignal("Signal
> >emitted>
> > at "+DateTime.Now);});
> >
> >     vbox.AddWidget(mySig);
> >   
> >     Show();
> >    }
> >
> >   [Q_SLOT]
> >     public void OnDialogIntClicked()
> >     {
> >       var dialog = new QInputDialog(this);
> >       dialog.inputMode = QInputDialog.InputMode.IntInput;
> >       dialog.Open();
> >             Connect(dialog, SIGNAL("intValueChanged(int)"), (int i) =>
> >
> > {Console.WriteLine("New Int value: '{0}'", i);});
> >
> >     }
> >
> >   [Q_SLOT]
> >     public void OnDialogTextClicked()
> >     {
> >       var dialog = new QInputDialog(this);
> >       dialog.inputMode = QInputDialog.InputMode.TextInput;
> >       dialog.Open();
> >       Connect(dialog, SIGNAL("textValueChanged(string)"), (string s) =>
> >
> > {Console.WriteLine("New Text value: '{0}'", s);});
> >
> >     }
> > 
> >   protected new IMySignals Emit {
> >     get {
> >       return (IMySignals) Q_EMIT;
> >     }
> >   }
> >
> >
> >    [STAThread]
> >      public static int Main(string[] args)
> >      {
> >        new QApplication(args);
> >        var app = new Dialog();
> >        return QApplication.Exec();
> >      }
> >
> > }
> > 
> > public interface IMySignals : IQWidgetSignals {
> >
> >         [Q_SIGNAL("mySignal(string)")]
> >         void MySignal(string val);
> >
> > }
> > 
> > 
> > cheers
> > Mat
> > _______________________________________________
> > Kde-bindings mailing list
> > Kde-bindings at kde.org
> > https://mail.kde.org/mailman/listinfo/kde-bindings
> 
> _______________________________________________
> Kde-bindings mailing list
> Kde-bindings at kde.org
> https://mail.kde.org/mailman/listinfo/kde-bindings
> 
> 
> 
> and slots as strings, I will only make sure they work with in the new Qyoto
> version.
> 
>     Dimitar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 665 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20131029/9c7ebb59/attachment-0001.sig>


More information about the Kde-bindings mailing list