Results 1 to 12 of 12

Thread: Query in 40000 chip demo

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Query in 40000 chip demo

    I am new to Qt and was exploring demos of Qt.
    I was trying the 40000 chip demo code and faced some confusion

    1) I want to know the significance of choosing -11000 to 11000 in the function void MainWindow::populateScene()

    2) if i change the loop, the chip movemment gets slow


    The loop in void MainWindow::populateScene() function is
    Qt Code:
    1. for (int i = -11000; i < 11000; i += 110) {
    2. ++xx;
    3. int yy = 0;
    4. for (int j = -7000; j < 7000; j += 70) {
    5. ++yy;
    6. qreal x = (i + 11000) / 22000.0;
    7. qreal y = (j + 7000) / 14000.0;
    8.  
    9. QColor color(image.pixel(int(image.width() * x), int(image.height() * y)));
    10. QGraphicsItem *item = new Chip(color, xx, yy);
    11. item->setPos(QPointF(i, j));
    12. scene->addItem(item);
    13.  
    14. ++nitems;
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    If i replace the loop with
    Qt Code:
    1. for (int i = 0; i < 22000; i += 110) {
    2. ++xx;
    3. int yy = 0;
    4. for (int j = 0; j < 14000; j += 70) {
    5. ++yy;
    6. qreal x = (i) / 22000.0;
    7. qreal y = (j) / 14000.0;
    8.  
    9. int w,h;
    10. w= image.width();
    11. h= image.height();
    12. QColor color(image.pixel(int(image.width() * x), int(image.height() * y)));
    13. QGraphicsItem *item = new Chip(color, xx, yy);
    14. item->setPos(QPointF(i, j));
    15. scene->addItem(item);
    16.  
    17.  
    18. ++nitems;
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

    and move the chips in the view, the movement is much slow.

    What am i missing here ???
    Last edited by jacek; 14th October 2006 at 18:36. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.