Esempio n. 1
0
        public T FindChild <T>(string name)
        {
            string childClassName = null;
            IntPtr metaObject     = IntPtr.Zero;

            if (SmokeMarshallers.IsSmokeClass(typeof(T)))
            {
                childClassName = SmokeMarshallers.SmokeClassName(typeof(T));
            }
            else
            {
                metaObject = (IntPtr)GCHandle.Alloc(Qyoto.GetMetaObject(typeof(T)));
            }

            IntPtr child = FindQObjectChild((IntPtr)GCHandle.Alloc(this), childClassName, metaObject, name);

            if (child != IntPtr.Zero)
            {
                try {
                    return((T)((GCHandle)child).Target);
                } catch (Exception e) {
                    Console.WriteLine("Found child, but an error has occurred: {0}", e.Message);
                    return(default(T));
                }
            }
            else
            {
                return(default(T));
            }
        }
Esempio n. 2
0
 public virtual QMetaObject MetaObject()
 {
     if (SmokeMarshallers.IsSmokeClass(GetType()))
     {
         return((QMetaObject)interceptor.Invoke("metaObject", "metaObject()", typeof(QMetaObject), false));
     }
     else
     {
         return(Qyoto.GetMetaObject(this));
     }
 }
Esempio n. 3
0
        public List <T> FindChildren <T>(QRegExp regExp)
        {
            List <T>    list  = new List <T>();
            AddToListFn addFn = delegate(IntPtr obj) {
                T o = (T)((System.Runtime.InteropServices.GCHandle)obj).Target;
                list.Add(o);
            };

            string childClassName = null;
            IntPtr metaObject     = IntPtr.Zero;

            if (SmokeMarshallers.IsSmokeClass(typeof(T)))
            {
                childClassName = SmokeMarshallers.SmokeClassName(typeof(T));
            }
            else
            {
                metaObject = (IntPtr)GCHandle.Alloc(Qyoto.GetMetaObject(typeof(T)));
            }
            FindQObjectChildren((IntPtr)GCHandle.Alloc(this), childClassName, metaObject, (IntPtr)GCHandle.Alloc(regExp), string.Empty, addFn);
            return(list);
        }