×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Location
    India
    Posts
    349

    Orientation problem in MeeGo Device

    Hi,
    I have a problem related to orientation in MeeGo Device. The app is already written for Symbian. The only problem is that when I run this app on MeeGo Harmattan Device (N950) it run in Landscape instead of Portrait and I just want to run this app in Portrait mode.

    The code I have used for Symbian is below, but I cant use this code for MeeGo because its a Symbian specific.

    #ifdef Q_OS_SYMBIAN
    CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
    TRAPD(error,
    if (appUi) {
    // Lock application orientation
    appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
    }
    );
    #endif

    Note: My application is not using QML/Qt Quick and right now I dont want to switch it from QWidget to QML.

    Kindly waiting for any right solution...

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Orientation problem in MeeGo Device

    Check QWidget::setAttribute() method.

  3. #3
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Orientation problem in MeeGo Device

    @narendar_discover: Harmattan X Server doesn't allow rotation. The ONLY way to make a QWidget-based applications run in portrait mode on Harmattan (N9/N950) is to embed the application UI inside QML.
    The solution could sound a bit difficult but actually it's not and it's matter of minutes.
    I wrote a widget proxy example which let you make your app working in portrait in few mins. [1].
    At [2] you can instructions.

    [1] https://gitorious.org/harmattanwidge...tarball/master
    [2] https://gitorious.org/harmattanwidge...mlproxy/README

    @savaj: to do what?

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Orientation problem in MeeGo Device

    I am talking about

    Code:
    QWidget::setAttribute(Qt::WA_LockPortraitOrientation, true);
    Widget Attribute Qt::WA_LockPortraitOrientation is available in Qt 4.7.4, but practically i never tested it on device, so just told them to check this method.

  5. #5
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Orientation problem in MeeGo Device

    @savaj: It doesn't work on Harmattan.

  6. #6
    Regular Contributor
    Join Date
    Oct 2007
    Location
    India
    Posts
    349

    Re: Orientation problem in MeeGo Device

    Thanks guys...
    Let me try too...

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Orientation problem in MeeGo Device

    Quote Originally Posted by gnuton View Post
    @savaj: It doesn't work on Harmattan.
    Never tried it on Harmattan, only tested it on Symbian

  8. #8
    Regular Contributor
    Join Date
    Sep 2010
    Posts
    150

    Re: Orientation problem in MeeGo Device

    Quote Originally Posted by gnuton View Post
    The ONLY way to make a QWidget-based applications run in portrait mode on Harmattan (N9/N950) is to embed the application UI inside QML.
    This is NOT the ONLY way and I think it is quite ugly-workaround-way to wrap c++ Qt code to QML just because orientation problem of meego. I mentioned in another topic that porting code from symbian or desktop Qt app means in this case to rewrite whole UI to QML stuff. Rewrite! - not reuse, not adjust a bit.

    The way without using QML:
    #include "mainwindow.h"

    #include <QtGui/QApplication>

    const int SCREEN_X = 480;
    const int SCREEN_Y = 854;

    #ifdef Q_OS_UNIX
    #include <QX11Info>
    #include <X11/Xatom.h>
    #include <X11/Xlib.h>
    #endif

    enum MyOrientation
    {
    Landscape = 0,
    Portrait = 270,
    LandscapeInverted = 180,
    PortraitInverted = 90
    };

    static void writeX11OrientationAngleProperty(QWidget* widget, MyOrientation orientation= Portrait)
    {
    #ifdef Q_WS_X11
    if (widget)
    {
    WId id = widget->winId();
    Display *display = QX11Info::display();
    if (!display) return;
    Atom orientationAngleAtom = XInternAtom(display, "_MEEGOTOUCH_ORIENTATION_ANGLE", False);
    XChangeProperty(display, id, orientationAngleAtom, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&orientation, 1);
    }
    #endif
    }

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QGraphicsScene scene;
    MainWindow w;
    scene.setSceneRect(0,0,SCREEN_X,SCREEN_Y);
    scene.addWidget(&w);

    QGraphicsView view(&scene);
    view.setGeometry(0,0,SCREEN_X,SCREEN_Y);
    view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    writeX11OrientationAngleProperty(&view);
    view.setStyleSheet( "QGraphicsView { border-style: none; }" );
    view.rotate(270);
    view.showFullScreen();

    return app.exec();
    }
    after this you can use MainWindow class (the child of QMainWindow) as usual in portrait mode.
    If you want to achieve rotation, then use Qt Mobility sensors for orientation.

    The only problem here that view.showFullScreen() hides system status bar with batery and signal strength indicators. I don't know yet how to make them visible. The regular view.show() works strange in this case. If someone knows how to show it, please, post it here.

  9. #9
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Orientation problem in MeeGo Device

    What's the difference between my way and your?
    Both embed QWidgets in a QGraphicsView (The Declarative view IS a GraphicsView).

    Embedding your app in QML Meego Components helps developer to have a more consistent app.
    In fact you have nice rotation effect and no problems with bars for free.
    If you need menus you can use the MeeGo ones, thing that you cannot have with your approach.

    Your approach is more basic and it has its pro and cons (as mine). I would personally recommended it if you are porting a game. In this case you don't want to "consume" (actually it's shared) memory for DeclarativeEngine, and you don't care about the integration with system.

  10. #10
    Regular Contributor
    Join Date
    Sep 2010
    Posts
    150

    Re: Orientation problem in MeeGo Device

    yes, you are right and I did not meant to say that your way is ugliest than mine, just want to say that there is not only one option
    ....and yes, both are workarounds for the situation of, I think, "non-finished porting" of Qt libs to Harmattan platform. I guess, the Qt team working on Harmattan platform adaptation just forgot about orientation issue and therefore there is no straight-forward way for developers now.

  11. #11
    Regular Contributor
    Join Date
    Oct 2007
    Location
    India
    Posts
    349

    Re: Orientation problem in MeeGo Device

    Quote Originally Posted by gnuton View Post
    @narendar_discover: Harmattan X Server doesn't allow rotation. The ONLY way to make a QWidget-based applications run in portrait mode on Harmattan (N9/N950) is to embed the application UI inside QML.
    The solution could sound a bit difficult but actually it's not and it's matter of minutes.
    I wrote a widget proxy example which let you make your app working in portrait in few mins. [1].
    At [2] you can instructions.

    [1] https://gitorious.org/harmattanwidge...tarball/master
    [2] https://gitorious.org/harmattanwidge...mlproxy/README

    @savaj: to do what?
    I have tested your sample app on RDA (Remote Device Access) N950. The application runs in landscape mode even I have fixed it to portrait.

    What can be problem ?

  12. #12
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Orientation problem in MeeGo Device

    It's hard to say without seeing the code.
    What kind of workaround are you using to rotate your QWidget-based app on harmattan?

  13. #13
    Regular Contributor
    Join Date
    Oct 2007
    Location
    India
    Posts
    349

    Re: Orientation problem in MeeGo Device

    I have used same code except following change:

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    to
    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationPortrait);

    inside qmlproxy/main.cpp

  14. #14
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Orientation problem in MeeGo Device

    The below code is used to lock the orientation in Portrait mode.

    Code:
    function lockToPortrait() {
         screen.allowedOrientation = Screen.Portrait
     }
    Regards,
    rahul

  15. #15
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Orientation problem in MeeGo Device

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); doesn't work on Harmattan.
    That's why you have embedded your app in the declarative view.

    Your mainview has been "transformed" in a declarative item and it has been embedded in a page.
    Well, now to lock your app in portrait you have to lock the page which contains your widget.

    for this purpose you have to set the orientationLock property inside your Page.

    Page {
    orientationLock: PageOrientation.LockPortrait

Similar Threads

  1. How to start my application on MeeGo device boot
    By mabdelaal in forum Nokia N9
    Replies: 9
    Last Post: 2011-09-22, 18:30
  2. Camera and device orientation
    By Sean_11 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2011-02-01, 06:41
  3. how to lock orientation in meego with QT
    By linlin_0 in forum Nokia N9
    Replies: 3
    Last Post: 2010-11-16, 08:57
  4. screen orientation problem with device
    By yatin_indianic in forum Mobile Java General
    Replies: 2
    Last Post: 2010-01-30, 04:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×