<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thanks, <br>
<br>
Qt.qobject_cast<> does the job. I won't promise you anything
but i might be able to help in testing (and spreading the word, of
course!). I still need to get acquainted to Qt and Qyoto. I'm
investigating gui libraries for csharp that work at least in Windows
and Mac's. If it gets approved, i'll be glad do help in testing.<br>
<br>
Regards<br>
<br>
Em 24-05-2012 23:03, Dimitar Dobrev escreveu:
<blockquote
cite="mid:1337897006.97202.YahooMailNeo@web125905.mail.ne1.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:times
new roman, new york, times, serif;font-size:12pt"><span>You're
welcome. :) I hope you will join our community, we could
definitely use any kind of help: development, testing,
popularisation among developers, etc.</span>
<div style="font-family: times new roman, new york, times,
serif; font-size: 12pt;">
<div style="font-family: times new roman, new york, times,
serif; font-size: 12pt;">
<div id="yiv1525107475">
<div>
<div
style="color:#000;background-color:#fff;font-family:times
new roman, new york, times, serif;font-size:12pt;">
<div><br>
</div>
<div>I've just checked "qt_rubberband" in a C++ Qt
project. The debugger shows it is as a QObject in an
empty QMainWindow, i.e. the same as in your C# code.
This probably means that Qyoto is in no error in
this case. About what "qt_rubberband" is, here is an
explanation -
<a class="moz-txt-link-freetext" href="http://www.qtcentre.org/threads/34998-qt_rubberband-blocking-events-of-pushbutton?p=161726#post161726">http://www.qtcentre.org/threads/34998-qt_rubberband-blocking-events-of-pushbutton?p=161726#post161726</a>.<br>
</div>
<div><br>
</div>
<div> Anyway, you may try casting it using the
Qt.qobject_cast<> static method.
Unfortunately, even if this works, I do not yet know
a way to test if such an object is of a certain type
(QWidget in this case).<br>
</div>
<div><br>
</div>
<div style="font-family:times new roman, new york,
times, serif;font-size:12pt;">
<div style="font-family:times new roman, new york,
times, serif;font-size:12pt;">
<div dir="ltr"> <font face="Arial" size="2">
<hr size="1"> <b><span
style="font-weight:bold;">From:</span></b>
Mach <a class="moz-txt-link-rfc2396E" href="mailto:metator.pt@gmail.com"><metator.pt@gmail.com></a><br>
<b><span style="font-weight:bold;">To:</span></b>
Dimitar Dobrev <a class="moz-txt-link-rfc2396E" href="mailto:dpldobrev@yahoo.com"><dpldobrev@yahoo.com></a>;
KDE bindings for other programming languages
<a class="moz-txt-link-rfc2396E" href="mailto:kde-bindings@kde.org"><kde-bindings@kde.org></a> <br>
<b><span style="font-weight:bold;">Sent:</span></b>
Friday, May 25, 2012 12:38 AM<br>
<b><span style="font-weight:bold;">Subject:</span></b>
Re: [Kde-bindings] [Qyoto] Casting QObjects<br>
</font> </div>
<br>
<div id="yiv1525107475">
<div> Hi Dimitar, <br>
<br>
Thank you for your quick reply. Well, i take
back what i said about traditional casting in
C#. Seems like this qt_rubberband object is
somewhat special (i don't have much experience
in Qt). For instance, following my example
this line of code returns null: QObject
rubberBand =
win.FindChild<QObject>("qt_rubberband");<br>
<br>
What i really find strange though, is that
qt_rubberband is considered to be only a
QObject. Shouldn't it be a QRubberBand (which
is a QWidget...)?<br>
<br>
Regards<br>
<br>
PS: I take this opportunity to thank you (and
also Steven Boswell regarding building Qyoto
in Windows) for making Qt available to
csharpers. <br>
<br>
Em 24-05-2012 21:42, Dimitar Dobrev escreveu:
<blockquote type="cite">
<div
style="color:#000;background-color:#fff;font-family:times
new roman, new york, times,
serif;font-size:12pt;">
<div><span>Hi, Mach,</span></div>
<div><br>
<span></span></div>
<div><span>On my machine your sample
behaves the same way with the addition
that traditional casting (that is,
replacing <br>
</span></div>
<div>QWidget widget = (QWidget)
child.MetaObject().Cast(child);</div>
<div><span><br>
</span></div>
<div><span>with</span></div>
<div><span><br>
</span></div>
<div><span></span><span>QWidget widget =
(QWidget) child;</span></div>
<div><span><br>
</span></div>
<div><span>work as well). </span><span>Apparently
</span><span>There is a bug in the </span>IsWidgetType
function because it allows the
"qt_rubberband" which the debugger shows
as a QObject only, to pass. However, "if
(child is QWidget)" works properly so
you can use that.<br>
</div>
<div><br>
</div>
<div style="font-family:times new roman,
new york, times, serif;font-size:12pt;">
<div style="font-family:times new roman,
new york, times,
serif;font-size:12pt;">
<div dir="ltr"> <font face="Arial"
size="2">
<hr size="1"> <b><span
style="font-weight:bold;">From:</span></b>
Mach <a moz-do-not-send="true"
rel="nofollow"
class="yiv1525107475moz-txt-link-rfc2396E"
ymailto="mailto:metator.pt@gmail.com" target="_blank"
href="mailto:metator.pt@gmail.com"><metator.pt@gmail.com></a><br>
<b><span style="font-weight:bold;">To:</span></b>
<a moz-do-not-send="true"
rel="nofollow"
class="yiv1525107475moz-txt-link-abbreviated"
ymailto="mailto:Kde-bindings@kde.org" target="_blank"
href="mailto:Kde-bindings@kde.org">Kde-bindings@kde.org</a>
<br>
<b><span style="font-weight:bold;">Sent:</span></b>
Thursday, May 24, 2012 10:54 PM<br>
<b><span style="font-weight:bold;">Subject:</span></b>
[Kde-bindings] [Qyoto] Casting
QObjects<br>
</font> </div>
<br>
Hi all,<br>
<br>
I've managed to compile qyoto on
windows and now i'm doing some test
applications to try it out. I'm having
trouble trying to downcast QObjects.
Traditional casting in C# does not
work, but i was expecting that. So i
started to look for something that
could perform a cast and found the
method Cast(QObject) in QMetaObject
but it's not working always. Below is
an example application that tries to
cast all the children of the main
window to widgets. Notice that i
previously check if the object is a
widget type:<br>
<br>
using System;<br>
using Qyoto;<br>
<br>
namespace QtTest {<br>
class Program {<br>
[STAThread]<br>
static void Main(string[]
args) {<br>
QApplication app = new
QApplication(args);<br>
QMainWindow win = new
QMainWindow();<br>
QPushButton btn = new
QPushButton(win);<br>
win.WindowTitle = "Demo
Application";<br>
win.Show();<br>
foreach (QObject child in
win.Children()) {<br>
if
(child.IsWidgetType()) {<br>
try {<br>
QWidget widget
= (QWidget)
child.MetaObject().Cast(child);<br>
Console.WriteLine("Cast succeeded.
It's now a " + widget.GetType().Name);<br>
} catch
(InvalidCastException e) {<br>
Console.WriteLine(child.ObjectName + "
of type " +
child.MetaObject().ClassName() +<br>
" cannot be cast to QWidget");<br>
}<br>
}<br>
}<br>
QApplication.Exec();<br>
}<br>
}<br>
}<br>
<br>
The output on the console is:<br>
<br>
qt_rubberband of type QRubberBand
cannot be cast to QWidget<br>
Cast succeeded. It's now a QPushButton<br>
<br>
I suspect this has something to do
with the fact that qt_rubberband was
created on the unmanaged side, whereas
QPushButton was created by the managed
side. I also tried calling
QWidget.StaticMetaObject.Cast(QObject)
but it's always returning null.<br>
<br>
Can someone help me out solving this
problem?<br>
<br>
Thanks in advance. Regards<br>
<br>
<br>
_______________________________________________<br>
Kde-bindings mailing list<br>
<a moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:Kde-bindings@kde.org"
target="_blank"
href="mailto:Kde-bindings@kde.org">Kde-bindings@kde.org</a><br>
<a moz-do-not-send="true"
rel="nofollow" target="_blank"
href="https://mail.kde.org/mailman/listinfo/kde-bindings">https://mail.kde.org/mailman/listinfo/kde-bindings</a><br>
<br>
<br>
</div>
</div>
</div>
<br>
<fieldset
class="yiv1525107475mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
Kde-bindings mailing list
<a moz-do-not-send="true" rel="nofollow" class="yiv1525107475moz-txt-link-abbreviated" ymailto="mailto:Kde-bindings@kde.org" target="_blank" href="mailto:Kde-bindings@kde.org">Kde-bindings@kde.org</a>
<a moz-do-not-send="true" rel="nofollow" class="yiv1525107475moz-txt-link-freetext" target="_blank" href="https://mail.kde.org/mailman/listinfo/kde-bindings">https://mail.kde.org/mailman/listinfo/kde-bindings</a>
</pre>
</blockquote>
<br>
</div>
</div>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kde-bindings mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kde-bindings@kde.org">Kde-bindings@kde.org</a>
<a class="moz-txt-link-freetext" href="https://mail.kde.org/mailman/listinfo/kde-bindings">https://mail.kde.org/mailman/listinfo/kde-bindings</a>
</pre>
</blockquote>
<br>
</body>
</html>