×

Discussion Board

Results 1 to 3 of 3

Hybrid View

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    2

    graphical issue with moving from landscape to portrait and back to landscape again

    Hi, I am going crazy. I making app where I turn on Auto Orientation of n900 device. And I have found a graphical glitch I cant resolve. I am new to Qt and c++ for that matter so probably why. But here is the description.

    App starts and rotating device switches between landscape and portrait. So if I am in landscape and open another ui form from a menu, it opens and the new form is portrait as I set its orientation to be portrait only. Also I should mention I put into stackedwindow mode. So from the 2nd form I push the back button to return to main screen, still holding n900 in portrait mode. But now the main screen shows the left half of landscape orientated main widget in the top half of the actual screen (since n900 is held in portrait). If I shake the device it will auto rotate the main widget into portrait but if you hold the n900 still and not move it wont auto correct. How do I solve this. How do I call it properly or how do I trigger a resize event? Here is my code;

    from cpp
    Code:
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    #ifdef Q_WS_MAEMO_5
        // Set stacked window attribute to the main window.
        setAttribute(Qt::WA_Maemo5StackedWindow);
        // Allow portrait mode.
        setAttribute(Qt::WA_Maemo5AutoOrientation, true);
    #endif
        // Call the setup of context menu of workoutsList QListWidget
        setupWorkoutsListContextMenu();
    
        // Setup SIGNAL to SLOT for detecting device rotation.
        connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
    
       statusBar()->showMessage("Begin");
    }
    
    void MainWindow::on_actionOpen_Timer_triggered()
    {
        /* Dont forget to add the frmtimer form header to this source file (e.g. #include <ui_frmtimer.h>).
           And dont forget to add the frmtimer form header to the header of this source file (e.g. add
            #include <frmtimer.h> to the mainwindow.h file.*/
        setWindowFlags(windowFlags() | Qt::Window);
        frmTimer *myTimerWindow = new frmTimer(this);
        //setAttribute(Qt::WA_Maemo5AutoOrientation, false);
        //setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
        myTimerWindow->show();
        //QMaemo5InformationBox::information(0, tr("called update orientation"));
    }
    
    void MainWindow::orientationChanged()
    {
        QRect screenGeometry = QApplication::desktop()->screenGeometry();
        if (screenGeometry.width() > screenGeometry.height())
        {
            //label->setText("<p align=\"center\">In Landscape Mode</p>");
            ui->statusBar->showMessage("Device in Landscape Mode");
            deviceLandscape = true;
            //ui->centralWidget->setLayoutDirection(Qt::WA_Maemo5LandscapeOrientation);
        }
        else
        {
            //label->setText("<p align=\"center\">In Portrait Mode</p>");
            ui->statusBar->showMessage("Device in Portrait Mode");
            deviceLandscape = false;
            //ui->centralWidget->setLayoutDirection(Qt::WA_Maemo5PortraitOrientation);
        }
    
    }
    code from 2nd form cpp
    Code:
    frmTimer::frmTimer(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::frmTimer)
    {
        ui->setupUi(this);
    #ifdef Q_WS_MAEMO_5
        setAttribute(Qt::WA_Maemo5StackedWindow);
        setAttribute(Qt::WA_Maemo5AutoOrientation, false);
        setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
    #endif
       // myMainWindow->orientationChanged();
    }
    
    frmTimer::~frmTimer()
    {
        delete ui;
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: graphical issue with moving from landscape to portrait and back to landscape agai

    windows children of other windows inherit the orientation attribute, but you have forced the second window to portrait.
    When the second window is shown I guess the windows on the back (the main window) skips some QWidget::update () since it's hidden.
    And if I got correctly...the composite manager does the rest.

    Maybe updating the main widget when the frmTimer is destroyed help:
    qobject_cast<QWidget*>(parent)->update();

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    2

    Re: graphical issue with moving from landscape to portrait and back to landscape agai

    Ok I gave that a shot but now I get a error of;
    /mAdaption/frmtimer.cpp:22: error: no matching function for call to 'qobject_cast(<unresolved overloaded function type>)'

    with this as the code;

    frmTimer::~frmTimer()
    {
    qobject_cast<QWidget*>(parent)->update();
    delete ui;
    }

Similar Threads

  1. Replies: 2
    Last Post: 2009-01-21, 22:28
  2. Landscape/Portrait orientation
    By greumatt in forum Symbian User Interface
    Replies: 6
    Last Post: 2009-01-07, 09:46
  3. Portrait/Landscape N95
    By IkerJ in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-09-12, 09:26
  4. MIDlet for Portrait and Landscape
    By bemar in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-07-26, 09:43

Posting Permissions

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