View previous topic :: View next topic |
Author |
Message |
Andrej08
Joined: 31 Aug 2010 Posts: 51
|
Posted: Sat Mar 12, 2011 6:25 pm Post subject: Usage of SLOT |
|
|
I'm trying to port the screenshot example to D2, but I'm stuck on this line:
Code: | QTimer.singleShot(delaySpinBox.value() * 1000, this, SLOT(shootScreen())); |
I can only find SLOT in qtd\d2\qt\QObjectDefs.d:
Code: | char[] SLOT( char[] a ) { return "1"~a; } |
But importing it fails as there's this import in the module:
Code: | //import qt.core.QGlobal;
//import qt.core.Qt;
import QGlobal; |
In any case I'm not sure how this is supposed to work? I can't pass an invocation of void method to a method expecting a char[]. And how does prepending "1" help?
It's hard to figure this stuff out without any comments.. |
|
Back to top |
|
|
mweber1488
Joined: 10 Jun 2008 Posts: 15
|
Posted: Sat Mar 12, 2011 9:17 pm Post subject: |
|
|
SLOT is just macro that wraps the parameter in quotes so you would use: Code: | QTimer.singleShot(delaySpinBox.value() * 1000, this, "shootScreen"); | Note that for the most part you do not need to tell qtd the slot parameters so for example QAbstractButton::checked(bool) would become Code: | connect(someObject, "some_signal", someButtonObject, "checked"); | The opengl example in the qtd package shows how qtd does signals and slots pretty well. |
|
Back to top |
|
|
Andrej08
Joined: 31 Aug 2010 Posts: 51
|
Posted: Sat Mar 12, 2011 10:24 pm Post subject: |
|
|
Thanks, I'll have a look there.
One more thing, when is it necessary to use mixin Q_OBJECT; ? Do I need it for all classes deriving from a QtD class? |
|
Back to top |
|
|
mweber1488
Joined: 10 Jun 2008 Posts: 15
|
Posted: Sun Mar 13, 2011 8:34 am Post subject: |
|
|
If your using the meta object system, then yes. |
|
Back to top |
|
|
|