Important: Please read the Qt Code of Conduct -

[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:
    ! centered: all is OK)!
    ! board in corner: all is OK)!

    But when I start the same on the Win7 x64 I see no splash, no score board...
    ! splash: it's bad)!
    ! 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.height()/2 - splash->pixmap().height()/2);
    } else
    QRectF right_shadow(scene_rect.right(), + 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);


    @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);
    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());


    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

    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).

Log in to reply