Results 1 to 12 of 12

Thread: Query in 40000 chip demo

  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

  2. #2
    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

    Exclamation Re: Query in 40000 chip demo

    None to solve the logical problem ????

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Query in 40000 chip demo

    Quote Originally Posted by aamer4yu View Post
    2) if i change the loop, the chip movemment gets slow
    Is it still slow after you restore the original version and recompile it? Maybe you have disabled the optimization or you do a debug build?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Query in 40000 chip demo

    Quote Originally Posted by aamer4yu View Post
    1) I want to know the significance of choosing -11000 to 11000 in the function void MainWindow:opulateScene()
    The scene (0,0) coordinate is in the middle of the scene.

  5. #5
    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 Re: Query in 40000 chip demo

    @ Jacek
    yes i tried rebuilding the application, using each loop

    @wysota,
    thx, even i guessed that it is in middle, in fact the aim of writing the new loop was to see how zoom would be affected if the middle is changed to top left

    So I would like to know how changing the middle cordinate of the scenen si affecting the speed of dragging ??

    Any help ?

  6. #6
    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

    Default Re: Query in 40000 chip demo

    @jacek... sorry didnt annwer u completely..
    well the original version runs fine when i restore to it.
    And ia m not using any optimization,,,using the defaults when i open the project in Visual Studio.
    The problem is occuring when i change the loop , making the middle cordinates as top left.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Query in 40000 chip demo

    Quote Originally Posted by aamer4yu View Post
    So I would like to know how changing the middle cordinate of the scenen si affecting the speed of dragging ??
    Why would it affect the speed of dragging? It is important for rotation of the canvas (it is rotated around the centre), nothing else.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Query in 40000 chip demo

    Quote Originally Posted by aamer4yu View Post
    The problem is occuring when i change the loop , making the middle cordinates as top left.
    Do I understand you correctly, that if you change that loop back to original version and recompile the example, it works faster?

  9. #9
    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

    Default Re: Query in 40000 chip demo

    @wysota even i want to know why was it affetcing the speed while dragging the chips..
    u can try urself...

    @jacek u r right... the original works fine,,, but whne i change it, the dragging becomes slow .. i amnot able to logically make out why is it happening

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Query in 40000 chip demo

    Quote Originally Posted by aamer4yu View Post
    @wysota even i want to know why was it affetcing the speed while dragging the chips..
    u can try urself...

    @jacek u r right... the original works fine,,, but whne i change it, the dragging becomes slow .. i amnot able to logically make out why is it happening
    It works fine for me... I don't experience any slowdowns.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Query in 40000 chip demo

    Quote Originally Posted by wysota View Post
    It works fine for me... I don't experience any slowdowns.
    For me too. I have both versions running side by side and I don't see any difference.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Query in 40000 chip demo

    Something else must have been changed in the code.

    @aamer4yu: Could you make a diff of the source code to see if there are any other differences outside the loop?

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.