Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt animated tiles example - question about QGraphics_
QtWS25 Last Chance

Qt animated tiles example - question about QGraphics_

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ecki
    wrote on last edited by
    #1

    For anybody who doesn't know the code of the Qt4.7.4 animated tiles example:

    @...
    int main(int argc, char **argv)
    {
    Q_INIT_RESOURCE(animatedtiles);

    QApplication app(argc, argv);
    
    QPixmap kineticPix(":/images/kinetic.png");
    
    • QPixmap kineticPix_(":/images/kinetic_.png");*
      QPixmap bgPix(":/images/Time-For-Lunch-2.jpg");
    QGraphicsScene scene(-350, -350, 700, 700);
    
    QList<Pixmap *> items;
    for (int i = 0; i < 64; ++i) {
    

    *Pixmap item = NULL;
    if ( i % 2 == 1 )
    {
    item = new Pixmap(kineticPix);
    } else
    {
    item = new Pixmap(kineticPix_);
    }

    item->setOffset(-kineticPix.width()/2, -kineticPix.height()/2);
    item->setZValue(i);
    items << item;
    scene.addItem(item);
    }
    ...@

    A few words to the changes. I have just changed the color of ":/images/kinetic.png" and I save this as ":/images/kinetic_.png".
    Then every even "Pixmap" should be the changed tile and every odd "Pixmap" should be the original tile. Then I compile this example.

    When execute the changed version of animated tiles all tiles look like the changed "Pixmap" ( ":/images/kinetic_.png")

    Here a picture:
    !http://i940.photobucket.com/albums/ad243/Ecki10686/changed_animated_tiles.jpg(changed_animated_tiles)!

    I have expected, that the tiles alternate.

    Is this a bug or which functions/method of QGraphics_ must I call to do, what I want?

    I embrace your answers.

    Bye Ecki

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      Edit your code, the * mean */ ?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stukdev
        wrote on last edited by
        #3

        And the solution is simply :) The image is not load, if you see the picture all is work! But the second image is not load! You see only 32 object of 64 :) The other 32 is 'hidden'.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Ecki
          wrote on last edited by
          #4

          Thanks. I fixed it.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved