Version: (using KDE 4.2.0) OS: Linux under ubuntu, when i try use QMouseEvent Buttons function an exeption is generate : cast invalid to uint.. code : using System; using Qyoto; public class maWidget : QWidget { //position dans le repere widget de click gauche QPoint p; bool b; public maWidget() : base(null, (uint)(Qt.WindowType.FramelessWindowHint | Qt.WindowType.SubWindow)) { b = false; Resize(300,300); QBitmap mask = new QBitmap(5,5); { QPainter p = new QPainter(mask); p.FillRect(mask.Rect() , Qt.GlobalColor.color0); p.SetPen(Qt.GlobalColor.color1); for (int i = 0 ; i < mask.Height() ; ++i) for(int j = 0 ; j< mask.Width() ; ++j) if( (i%2 ^ j%2) != 0) p.DrawPoint(j,i); } mask = new QBitmap(mask.Scaled( this.Size )); SetMask(mask); } protected override void MousePressEvent ( QMouseEvent mouseEvent ) { if(mouseEvent.Button() == Qt.MouseButton.LeftButton) { p = mouseEvent.Pos(); b = true; } } protected override void MouseReleaseEvent ( QMouseEvent mouseEvent ) { if(mouseEvent.Button() == Qt.MouseButton.LeftButton) { b = false; } } protected override void MouseMoveEvent ( QMouseEvent mouseEvent ) { uint but = mouseEvent.Buttons(); // <= cast exeption if(b) { QPoint po= mouseEvent.GlobalPos() - p; Move(po.X(),po.Y() ); } } } public class Test { public static int Main(String[] args) { QApplication app = new QApplication(args); maWidget w = new maWidget(); w.Show(); return QApplication.Exec(); } }
This bug is under ubuntu 8.04
works perfectly for me. could you post the exact error message and backtrace for the crash?
i look my ubuntu version. It's 8.04. So i try an old mono and qyoto version. So it's certainly an old bug. Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type. at Qyoto.QMouseEvent.Buttons () [0x00000] at maWidget.MouseMoveEvent (Qyoto.QMouseEvent mouseEvent) [0x00000] in /home/mongaulois/testqyoto/testqyoto/test.cs:55 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[]) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] --- End of inner exception stack trace --- at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] at Qyoto.SmokeInvocation.InvokeMethod (IntPtr instanceHandle, IntPtr methodHandle, IntPtr stack) [0x00000] at (wrapper native-to-managed) Qyoto.SmokeInvocation:InvokeMethod (intptr,intptr,intptr) at (wrapper managed-to-native) Qyoto.SmokeInvocation:CallSmokeMethod (int,intptr,intptr,int) at Qyoto.SmokeInvocation.Invoke (System.String mungedName, System.String signature, System.Type returnType, System.Object[] args) [0x00000] at Qyoto.QApplication.Exec () [0x00000] at Test.Main (System.String[] args) [0x00013] in /home/mongaulois/testqyoto/testqyoto/test.cs:74
i test ubuntu 9.04 all works perfectly :)