Good time of the day!
I'm struggling for two days with a problem, which appears with the android build (latest Qt 5.1 and Qt Creator 2.7.2) on WinXP (but I think it don't matter), latest NDK, SDK, and WinAnt. In two words, android app always uses 640x480 resolution! The problem disappers once when I manually cleaned all the files built in the project, including *.pro.user, and rebuilt project from scratch. But one build later the problem returns (code changes cannot affect this, I'm sure). I didn't tried for more than one time to cleanup the project, because I think the problem is not in project properties (which hasn't changed between launches).
Please at picture attached. The situation is not only on emulator occurs, but on the real device too. However, windows app running as expected.
The actual code is the following:
main.cpp
Code:
#include "mainwindow.h" #include "mainwidget.h" #include <QApplication> #include <QTime> int main(int argc, char *argv[]) { MainWindow main_window; main_window.showMaximized(); main_window.setCentralWidget(new MainWidget(&main_window)); return app.exec(); }
mainwindow.h
Code:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> { Q_OBJECT public: ~MainWindow(); }; #endif // MAINWINDOW_H
mainwidget.h
Code:
#ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QGraphicsView> class QGraphicsScene; class QImage; class QGraphicsPixmapItem; { Q_OBJECT public: protected: private: void createGameScene(); QGraphicsScene * scene; QWidget * parent; private slots: void unsetSplash(); }; #endif // MAINWIDGET_H
[/code]
mainwindow.cpp
Code:
#include "mainwindow.h" setStyleSheet("background-color: darkGrey;"); } MainWindow::~MainWindow() { }
mainwidget.cpp
Code:
#include "mainwidget.h" #include <QGraphicsScene> #include <QGraphicsPixmapItem> #include <QTimer> setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(FullViewportUpdate); } scene->setSceneRect(20, 20, parent->geometry().width() - 20, parent->geometry().height() - 20); if (splash) splash->setPos(mapToScene(rect.width()/2 - splash->pixmap().width()/2, rect.height()/2 - splash->pixmap().height()/2)); if (right_shadow.intersects(rect) || right_shadow.contains(rect)) painter->fillRect(right_shadow, Qt::darkGray); if (bottom_shadow.intersects(rect) || bottom_shadow.contains(rect)) painter->fillRect(bottom_shadow, Qt::darkGray); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, Qt::lightGray); painter->fillRect(rect.intersected(scene_rect), gradient); painter->setBrush(Qt::NoBrush); painter->drawRect(scene_rect); } void MainWidget::unsetSplash() { scene->removeItem(splash); delete splash; splash = 0; createGameScene(); update(); } void MainWidget::createGameScene() { score->setPos(mapToScene(scene->sceneRect().top(),scene->sceneRect().left())); redMeeple->setPos(score->boundingRect().left() + 30, score->boundingRect().bottom() - 20); blueMeeple->setPos(score->boundingRect().left() + 60, score->boundingRect().bottom() - 20); }
*.pro file
Code:
#------------------------------------------------- # # Project created by QtCreator 2013-07-16T22:21:30 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = Discovery TEMPLATE = app RESOURCES = discovery.qrc SOURCES += main.cpp\ mainwindow.cpp \ mainwidget.cpp HEADERS += mainwindow.h \ mainwidget.h CONFIG += mobility MOBILITY = OTHER_FILES += \ android/AndroidManifest.xml \ android/res/layout/splash.xml \ android/res/values/libs.xml \ android/res/values/strings.xml \ android/res/values-de/strings.xml \ android/res/values-el/strings.xml \ android/res/values-es/strings.xml \ android/res/values-et/strings.xml \ android/res/values-fa/strings.xml \ android/res/values-fr/strings.xml \ android/res/values-id/strings.xml \ android/res/values-it/strings.xml \ android/res/values-ja/strings.xml \ android/res/values-ms/strings.xml \ android/res/values-nb/strings.xml \ android/res/values-nl/strings.xml \ android/res/values-pl/strings.xml \ android/res/values-pt-rBR/strings.xml \ android/res/values-ro/strings.xml \ android/res/values-rs/strings.xml \ android/res/values-ru/strings.xml \ android/res/values-zh-rCN/strings.xml \ android/res/values-zh-rTW/strings.xml \ android/src/org/kde/necessitas/ministro/IMinistro.aidl \ android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl \ android/src/org/qtproject/qt5/android/bindings/QtActivity.java \ android/src/org/qtproject/qt5/android/bindings/QtApplication.java \ android/version.xml \ android/AndroidManifest.xml \ android/res/layout/splash.xml \ android/res/values/libs.xml \ android/res/values/strings.xml \ android/res/values-de/strings.xml \ android/res/values-el/strings.xml \ android/res/values-es/strings.xml \ android/res/values-et/strings.xml \ android/res/values-fa/strings.xml \ android/res/values-fr/strings.xml \ android/res/values-id/strings.xml \ android/res/values-it/strings.xml \ android/res/values-ja/strings.xml \ android/res/values-ms/strings.xml \ android/res/values-nb/strings.xml \ android/res/values-nl/strings.xml \ android/res/values-pl/strings.xml \ android/res/values-pt-rBR/strings.xml \ android/res/values-ro/strings.xml \ android/res/values-rs/strings.xml \ android/res/values-ru/strings.xml \ android/res/values-zh-rCN/strings.xml \ android/res/values-zh-rTW/strings.xml \ android/src/org/kde/necessitas/ministro/IMinistro.aidl \ android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl \ android/src/org/qtproject/qt5/android/bindings/QtActivity.java \ android/src/org/qtproject/qt5/android/bindings/QtApplication.java \ android/version.xml
Please help me to solve the issue, I can't develop further with this behavior.
Thanks in advance, Andrey