September 15, 2010

vasylp vasylp
Lab Rat
12 posts

QMainWindow layout bug in landscape mode on Symbian S60v5 and Symbian^3

 

When I put many widgets in QMainWindow, it shows them normal in portrait mode, but in landscape mode these widgets are stretching out of the screen and become inaccessible. I’ve reproduced it on Nokia 5800ExpressMusic and Nokia N8 with the same result. Qt version is 4.6.3.

Here some screenshots of the sample application: Portrait mode [pixelpipe.com], Landscape mode [pixelpipe.com]

Here is the code:

  1. #include <QApplication>
  2. #include <QVBoxLayout>
  3. #include <QPushButton>
  4. #include <QCheckBox>
  5. #include <QTextEdit>
  6. #include <QMainWindow>
  7.  
  8. int main (int argc, char * argv[])
  9. {
  10.   QApplication app(argc, argv);
  11.   QMainWindow wnd;
  12.   QWidget* window = new QWidget;
  13.   QVBoxLayout* layout = new QVBoxLayout(window);
  14.   QPushButton* optsButton = new QPushButton("Options");
  15.   QPushButton* exitButton = new QPushButton("Exit");
  16.   QCheckBox* chkBox = new QCheckBox("Checkbox");
  17.   QTextEdit* textEd1 = new QTextEdit;
  18.   QTextEdit* textEd2 = new QTextEdit;
  19.   layout->addWidget(textEd1);
  20.   layout->addWidget(textEd2);
  21.   layout->addWidget(chkBox);
  22.   layout->addWidget(optsButton);
  23.   layout->addWidget(exitButton);
  24.  
  25.   QObject::connect(exitButton, SIGNAL(clicked()), &app, SLOT(quit()));
  26.  
  27.   wnd.setCentralWidget(window);
  28.  
  29. #if defined(Q_WS_S60)
  30.   wnd.showMaximized();
  31. #else
  32.   wnd.show();
  33. #endif
  34.   return app.exec();
  35. }

Is it bug or maybe I’m doing something wrong?


Best regards,
VP

2 replies

September 16, 2010

johnk johnk
Lab Rat
56 posts

Hello Vasyl,

I just wrote an article [developer.symbian.org] about lists on Symbian devices. While the focus is on customizing lists, it also addresses handling a resize event for orientation and laying the widgets properly. You might check it out.

-hth
John

September 17, 2010

khris khris
Lab Rat
19 posts

Use setLayout() method after add widgets to layout. If not, window can’t use layout as a layout manager.

 Signature 

Let it be, let it be, let it be, walk your way.

 
  ‹‹ Maybe bug in QScrollArea::setWidgetResizable(true)      Qt Mobility - Placing a Call ››

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