mapwidget.cpp 797 B

12345678910111213141516171819202122232425262728293031
  1. #include "mapwidget.h"
  2. #include "ui_mapwidget.h"
  3. #include <QtGui>
  4. MapWidget::MapWidget(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::MapWidget)
  7. {
  8. ui->setupUi(this);
  9. //setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
  10. setAttribute(Qt::WA_Maemo5AutoOrientation, true);
  11. connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
  12. }
  13. MapWidget::~MapWidget()
  14. {
  15. delete ui;
  16. }
  17. void MapWidget::orientationChanged()
  18. {
  19. QRect screenGeometry = QApplication::desktop()->screenGeometry();
  20. if (screenGeometry.width() > screenGeometry.height())
  21. ui->label->setText("<p align=\"center\">In Landscape Mode</p>");
  22. else
  23. ui->label->setText("<p align=\"center\">In Portrait Mode</p>");
  24. }