September 17, 2011

Cathryne Cathryne
Lab Rat
2 posts

Making the status pane disappear, but not the control pane. (softkeys?)

 

Okay! So I have kind of hit a road bump in my app, I’ve been trying to make the Statuspane disappear, while keeping the control pane. I simply can’t seem to make it work. I’ve been trying to follow and understand this example: http://doc.qt.nokia.com/latest/widgets-softkeys.html but with limited C++ knowledge and even less with the Qt Creator, I have found myself at a bit of a road bump. I have tried various things for hours, but what I’m currently sitting with is:

mainwindow.h:

  1. #include "mainwindow.h"
  2.  
  3. #include <QtGui/QApplication>
  4. #include <QtGui>
  5.  
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.     QApplication app(argc, argv);
  10.  
  11.     MainWindow mainWindow;
  12.     mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
  13.    // mainWindow.showExpanded();
  14.     mainWindow.showMaximized();
  15.  
  16.     return app.exec();
  17. }

and in my mainwindow.cpp I’ve added a void like this, nothing else related to what I want:

  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. #include <QtCore/QCoreApplication>
  5. #include <QtGui>
  6. #include <Qt>
  7. #include <QFlags>
  8.  
  9. MainWindow::MainWindow(QWidget *parent)
  10.     : QMainWindow(parent), ui(new Ui::MainWindow)
  11. {
  12.     ui->setupUi(this);
  13.  
  14.  
  15. }
  16.  
  17. MainWindow::~MainWindow()
  18. {
  19.     delete ui;
  20. }
  21.  
  22. void MainWindow::setOrientation(ScreenOrientation orientation)
  23. {
  24. #if defined(Q_OS_SYMBIAN)
  25.     // If the version of Qt on the device is < 4.7.2, that attribute won't work
  26.     if (orientation != ScreenOrientationAuto) {
  27.         const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
  28.         if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
  29.             qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
  30.             return;
  31.         }
  32.     }
  33. #endif // Q_OS_SYMBIAN
  34.  
  35.     Qt::WidgetAttribute attribute;
  36.     switch (orientation) {
  37. #if QT_VERSION < 0x040702
  38.     // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
  39.     case ScreenOrientationLockPortrait:
  40.         attribute = static_cast<Qt::WidgetAttribute>(128);
  41.         break;
  42.     case ScreenOrientationLockLandscape:
  43.         attribute = static_cast<Qt::WidgetAttribute>(129);
  44.         break;
  45.     default:
  46.     case ScreenOrientationAuto:
  47.         attribute = static_cast<Qt::WidgetAttribute>(130);
  48.         break;
  49. #else // QT_VERSION < 0x040702
  50.     case ScreenOrientationLockPortrait:
  51.         attribute = Qt::WA_LockPortraitOrientation;
  52.         break;
  53.     case ScreenOrientationLockLandscape:
  54.         attribute = Qt::WA_LockLandscapeOrientation;
  55.         break;
  56.     default:
  57.     case ScreenOrientationAuto:
  58.         attribute = Qt::WA_AutoOrientation;
  59.         break;
  60. #endif // QT_VERSION < 0x040702
  61.     };
  62.     setAttribute(attribute, true);
  63. }
  64.  
  65. void MainWindow::showExpanded()
  66. {
  67. #ifdef Q_OS_SYMBIAN
  68.     showFullScreen();
  69. #elif defined(Q_WS_MAEMO_5)
  70.     showMaximized();
  71. #else
  72.     show();
  73. #endif
  74. }
  75.  
  76.  
  77.  
  78. void MainWindow::setMode()
  79. {
  80.     Qt::WindowFlags flags = windowFlags();
  81.     flags |= Qt::WindowSoftkeysVisibleHint;
  82.     flags &= ~Qt::WindowSoftkeysRespondHint;
  83.     setWindowFlags(flags); // Hides visible window
  84.     showFullScreen();
  85.  
  86. }

I’ve tried switching the flags around, I’ve tried switching the second if a bit, but I can’t seem to make it work. All I want is to remove the status pane, while keeping the softkeys, but this is sooo frustrating. I hope someone has had to deal with this before.

Edit: I forgot to mention, this is a Mobile Application, specifically made for Symbian^3, at this stage at least. I have tried endless times to make this work by various means, I have searched the web over and over in an attempt of finding another answer or someone who knew what to do. But it usually comes back to the softkeys example.

1 reply

September 19, 2011

sriks sriks
Lab Rat
122 posts

According to the code you supplied, where are you calling setMode(). What you are doing in setMode should serve the purpose.

 
  ‹‹ [Moved] API for signIn to Ovi services      Problem using Binding QML element ››

You must log in to post a reply. Not a member yet? Register here!