Results 1 to 2 of 2

Thread: need help .not able to understand.......

  1. #1
    Join Date
    Nov 2008
    Posts
    52
    Qt products
    Qt4
    Platforms
    Windows

    Default need help .not able to understand.......

    I got the program in which image gets rotated.But here the original image doesn't get displayed.Instead the image is displayed as zoomed & every pixel looks like a chip(i.e.IC).The following is the function which does zooming:

    Qt Code:
    1. void MainWindow::PopulateScene()
    2. {
    3. scene = new QGraphicsScene;
    4.  
    5. QImage image(":/qt4logo.png");
    6.  
    7. // Populate scene
    8. int xx = 0;
    9. int nitems = 0;
    10. for (int i = -11000; i < 11000; i += 110) {
    11. ++xx;
    12. int yy = 0;
    13. for (int j = -7000; j < 7000; j += 70) {
    14. ++yy;
    15. qreal x = (i + 11000) / 22000.0;
    16. qreal y = (j + 7000) / 14000.0;
    17.  
    18. QColor color(image.pixel(int(image.width() * x), int(image.height() * y)));
    19. QGraphicsItem *item = new Chip(color, xx, yy);
    20. item->setPos(QPointF(i, j));
    21. scene->addItem(item);
    22.  
    23. ++nitems;
    24. }
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 
    This is from the program chip.The path is as follows:\Qt\4.4.3\demos\chip.
    I want to know how the original image can be displayed instead of zoomed one.Please help
    Last edited by jpn; 20th January 2009 at 07:22. Reason: missing [code] tags

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

    Default Re: need help .not able to understand.......

    Definitely not like this

    Try this instead:
    Qt Code:
    1. gv->setScene(new QGraphicsScene);
    2. gv->scene()->addPixmap(QPixmap("somepixmap.png"));
    3. gv->show();
    To copy to clipboard, switch view to plain text mode 
    And next time please try to find some code snippet or documentation paragraph that is at least somewhat similar to your problem.

Similar Threads

  1. Don't understand Q_OBJECT
    By Cruz in forum Newbie
    Replies: 4
    Last Post: 19th January 2009, 12:26
  2. QFontMetrics, i can't understand
    By pakulo in forum Qt Programming
    Replies: 11
    Last Post: 24th June 2007, 17:59
  3. QProgressBar: don't understand in details, help me !!!
    By haconganh in forum Qt Programming
    Replies: 5
    Last Post: 10th May 2007, 08:07

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.