12-10-2012 02:30 PM
smiley wrote:
I have followed the above code and even the sample app and yet my app won't receive the orientation changes.
Is there something that I have missed?
in the bar-descriptor - application - set orientation to auto-orient
12-10-2012 02:56 PM
ekke wrote:
smiley wrote:
I have followed the above code and even the sample app and yet my app won't receive the orientation changes.
Is there something that I have missed?
in the bar-descriptor - application - set orientation to auto-orient
I have done that.
<initialWindow>
<autoOrients>true</autoOrients>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
</initialWindow>
The screen does rotate but i'm not receiving the events. Here is the code
main cpp
OrientationSupport::instance()->setSupportedDisplayOrientation(SupportedDisplayOrientation::All); QObject::connect( OrientationSupport::instance(), SIGNAL(orientationAboutToChange(bb::cascades::UIOr ientation::Type)), this, SLOT(onOrientationAboutToChange(bb::cascades::UIOr ientation::Type))); QObject::connect( OrientationSupport::instance(), SIGNAL(orientationChanged(bb::cascades::UIOrientat ion::Type)), this, SLOT(onOrientationChanged(bb::cascades::UIOrientat ion::Type)));
Slots
void testApp::onOrientationAboutToChange(UIOrientation::Type orientation) { } void testApp::onOrientationChanged(UIOrientation::Type orientation) { }
in hpp file
public slots: void onOrientationAboutToChange(UIOrientation::Type orientation); void onOrientationChanged(UIOrientation::Type orientation);
thanks
12-10-2012 03:22 PM
is the slot never getting called or you're not getting the proper orientation?
There is currently a bug in beta4 where the argument 'orientation' in the orientationChanged signal is never of type Landscape. You have to use OrientationSupport.orientation to detect whether landscape or portrait.
12-10-2012 03:50 PM
the slot is never called.
I'm using Beta 3 SDK with the lastest alpha OS.
12-10-2012 03:53 PM
your connect is probably wrong then...
where exactly are you calling the connect code ?
12-10-2012 05:12 PM
lew wrote:
your connect is probably wrong then...
where exactly are you calling the connect code ?
TestApp::TestApp(bb::cascades::Application *app)
: QObject(app)
{
OrientationSupport::instance()->setSupportedDispla yOrientation(SupportedDisplayOrientation::All);
QObject::connect(
OrientationSupport::instance(),
SIGNAL(orientationAboutToChange(bb::cascades::UIOr ientation::Type)),
this,
SLOT(onOrientationAboutToChange(bb::cascades::UIOr ientation::Type)));
QObject::connect(
OrientationSupport::instance(),
SIGNAL(orientationChanged(bb::cascades::UIOrientat ion::Type)),
this,
SLOT(onOrientationChanged(bb::cascades::UIOrientat ion::Type)));
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(th is);
...
}
12-11-2012 01:35 AM
that code looks fine to me...maybe there is a bug somewhere with when the signals should be connected?
can you try doing it in QML (as i know this one works fine):
onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
OrientationSupport.orientationChanged.connect(onOr
}
have the slot within the QML for the time being. if it works, you can connect the signal to your c++ slot.
let me know if it works!
PS: one more thing, putting aside the signal, does your device screen rotate at all?
12-11-2012 10:37 AM
lew wrote:
that code looks fine to me...maybe there is a bug somewhere with when the signals should be connected?
can you try doing it in QML (as i know this one works fine):
onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
OrientationSupport.orientationChanged.connect(onOrientationChanged);
}
have the slot within the QML for the time being. if it works, you can connect the signal to your c++ slot.
let me know if it works!
PS: one more thing, putting aside the signal, does your device screen rotate at all?
Thanks but i have tried in QML first.
OrientationHandler {
id: handler
onOrientationAboutToChange: {
// set some UI to be shown during orientation change
if (orientation == UIOrientation.Portrait) {
// make some ui changes related to portrait
} else if (orientation == UIOrientation.Landscape) {
// make some ui changes related to landscape
}
if (displayDirection == DisplayDirection.North) {
// do something specific to this device display direction
}
}
onOrientationChanged: {
// can update the UI after the orientation changed
}
onDisplayDirectionChanged: {
// can perform actions based on the direction of the display
}
},
In QML editor it would give error onOrientationAboutToChange. It has unknown.
and yes it does rotate the screen just not getting the signal.
12-11-2012 02:19 PM
your QML code is wrong....probably the documentation still hasn't been updated ![]()
DO NOT use the orientationHandler, it is no longer the way to get the orientation events...use the code i supplied above.
onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
OrientationSupport.orientationChanged.connect(onOr ientationChanged);
}