[SOLVED] qgraphicsview/scene: qt executable under Win7 works unexpected way
-
Hi all!
When I start on my computer (WinXP x32 with Qt 5.1/QtCreator 2.7.2) the binary with appropriate dll's, I see those pictures:
!http://s3.hostingkartinok.com/uploads/images/2013/07/14707e3f9683b44cbefa7414af9bb3e7.png(Splash centered: all is OK)!
!http://s4.hostingkartinok.com/uploads/images/2013/07/0c6417b149f51ca26431e24275dd64c0.png(Score board in corner: all is OK)!But when I start the same on the Win7 x64 I see no splash, no score board...
!http://s2.hostingkartinok.com/uploads/images/2013/07/b644ca4c0dca1b9bf90d639fd942bbee.png(No splash: it's bad)!
!http://s3.hostingkartinok.com/uploads/images/2013/07/d2d774de37948b2070c57ac8342be8f1.png(Items have gone out: it's bad)!For information: android build works as expected.
The actual code in methods of QGraphicsView inherited class:
@void MainWidget::drawBackground(QPainter *painter, const QRectF& rect) {
scene->setSceneRect(20, 20, geometry().width() - 20, geometry().height() - 20);
QRectF scene_rect = scene->sceneRect();if (splash) { splash->setPos(scene_rect.left() + scene_rect.width()/2 - splash->pixmap().width()/2, scene_rect.top() + scene_rect.height()/2 - splash->pixmap().height()/2); return; } else setCacheMode(CacheBackground); QRectF right_shadow(scene_rect.right(), scene_rect.top() + 5, 5, scene_rect.height()); QRectF bottom_shadow(scene_rect.left() + 5, scene_rect.bottom(), scene_rect.width(), 5); 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); QLinearGradient gradient(scene_rect.topLeft(), scene_rect.bottomRight()); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, Qt::lightGray); painter->fillRect(scene_rect, gradient); painter->setBrush(Qt::NoBrush); painter->drawRect(scene_rect);
}@
@void MainWidget::createGameScene() {
scene->addItem(score = new QGraphicsPixmapItem(QPixmap(":/images/DiscoveryScore.jpg")));
score->setPos(scene->sceneRect().left(), scene->sceneRect().top());
scene->addItem(redMeeple = new QGraphicsPixmapItem(QPixmap(":/images/DiscoveryRedMeeple.png")));
redMeeple->setPos(scene->sceneRect().left() + 5,
scene->sceneRect().top() + score->boundingRect().height() - redMeeple->boundingRect().height());
scene->addItem(blueMeeple = new QGraphicsPixmapItem(QPixmap(":/images/DiscoveryBlueMeeple.png")));
blueMeeple->setPos(scene->sceneRect().left() + 35,
scene->sceneRect().top() + score->boundingRect().height() - blueMeeple->boundingRect().height());TileItem * starter = new TileItem(this); starter->setTileNumber(0, true); starter->setI(84); starter->setJ(84); starter->setPut(); starter->setFlag(QGraphicsItem::ItemIsMovable, false); starter->setPos(scene->sceneRect().left() + scene->sceneRect().width()/2 - starter->pixmap().width()/2, scene->sceneRect().top() + scene->sceneRect().height()/2 - starter->pixmap().height()/2); scene->addItem(starter); tilesMap[84][84] = starter; for (qint8 i = 1; i < 84; ++i) restTiles << i; TileItem * first_tile = new TileItem(this); first_tile->setTileNumber(qrand() % 83 + 1); first_tile->setPos(score->boundingRect().width() + scene->sceneRect().left() - first_tile->boundingRect().width(), score->boundingRect().height() + scene->sceneRect().top()); scene->addItem(first_tile);
}@
Maybe I'm incorrect in usage of QGraphicsView/QGraphicsScene? But why it works on XP and android? I've also tried Win7x32... the same behavior (inappropriate), as the Win7x64. But on two different real android devices, emulator and winxp works fine. What can be the matter??
Thanks in advance, Andrey
SOLUTION
Have found the solution. In deployment Windows documentation is nothing about need of adding imageformats/ folder in package. JPEG pictures were the problem without adding imageformats (png are ok).