[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bindings
Subject:    Re: [Kde-bindings] Qyoto: SIGNALS/SLOTS
From:       Arno Rehn <kde-bindings () arnorehn ! de>
Date:       2005-12-17 19:43:08
Message-ID: 200512172043.08260.kde-bindings () arnorehn ! de
[Download RAW message or body]

Am Donnerstag, 15. Dezember 2005 14:32 schrieb Arno Rehn:
> Am Mittwoch, 14. Dezember 2005 20:22 schrieb Adam Treat:
> > On Wednesday December 14 2005 1:43 pm, you wrote:
> > > Hi,
> > >
> > > I found the following in you code:
> > > IntPtr s = (this.Instance as QtSharp).RawObject;
> > >
> > > does 'RawObject' point to the underlying C++ instance?
> > > If it does, a second question: How do I get the pointer to the
> > > C++-instance? It tried it with 'GCHandle.Alloc' but that doesn't seem
> > > to work.
> >
> > Yes, it does.  You can find the code for RawObject and the handling of
> > C++ pointer interaction in the attached file.
>
> Thanks, but here I referr to the smoke-lib. I think we can use the
> functions of libqtsharp to connect signals to slots. I just wanted to try
> to use libqtsharp with the smoke-bindings. Therefore I would need to get
> the pointer to the instance of the object in the smoke-lib.

OK, here is what I try to do: I want to use libqtsharp to connect a signal to 
a slot. I looked in the files Adam sent and discovered how he connects a 
signal to a C#-delegate. He uses 'RawObject' to get the pointer to the 
C++-instance. I want to connect a signal to a delegate in the same way, but I 
need to get the pointer to the C++-instance created by smoke. I changed 
"_smokeObject" (in Qt.cs) from "private" to "public" to access it outsides 
the class. I then tried to call 'csharp_connect_void' to connect a signal to 
a delegate but that failed. I think '_smokeObject' doesn't point to the real 
C++-instance. I attached my code.
Maybe Richard can help getting the appropiate IntPtr needed for the 
function-call.

-- 
Arno Rehn
arno@arnorehn.de

["signaltest.cs" (text/x-c++src)]

// project created on 09.12.2005 at 16:44
using System;
using System.Runtime.InteropServices;
using System.Reflection;
using Qt;

class MainClass : QDialog
{
	[DllImport("libqtsharp", CharSet=CharSet.Ansi)]
	private static extern IntPtr csharp_connect_void (IntPtr sender, string signal, \
IntPtr receiver, Delegate cb);

	public delegate void del_void();
	
	static QApplication qapp;
	
	
	
	public void myconnect() {
		Delegate del;
		del = Delegate.CreateDelegate (typeof (del_void), this, "signaldele");
		
		csharp_connect_void(qapp._smokeObject, "2lastWindowClosed()", this._smokeObject, \
del);  }
	
	public void signaldele()
	{
		Console.WriteLine("*************\nsignaldele was called\n*************");
	}
	
	public static void Main(string[] args)
	{
		qapp = new QApplication(args);
		
		MainClass mc = new MainClass();
		
		qapp.SetMainWidget(mc);
		mc.Show();
		
		qapp.Exec();
	}
	
	public MainClass()
	{
		myconnect();
	}
	
	public void WriteSth(string Text)
	{
		Console.WriteLine("WriteSth: " + Text);
	}
	
	public static string GetDeleName(object thedele)
	{
		Type t = thedele.GetType();
		return t.Name;
	}
}



_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic