Results 1 to 20 of 21

Thread: QGraphics View

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphics View

    Dear All,

    I have developed a application using QGraphicsScene and QGraphicPixmapItem. In the application I'm adding pixmaps on the graphic scene. Initially I'm inserting
    Pixmap based on timer event for 1 seconds. On the same scene I need to insert second pixmap manually by pushbutton event. Im sharing the code here.plz help me, where I'm making mistake. I have attached output screen shot also.
    Qt Code:
    1. SERVER::SERVER(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::SERVER)
    4. {
    5. ui->setupUi(this);
    6.  
    7. scene=new QGraphicsScene(0,0,740,400);
    8. scene=new QGraphicsScene(ui->graphicsView);
    9.  
    10. int x=50;
    11. int y=50;
    12.  
    13. timer.start(1000);
    14.  
    15. //other declarations line edit, push buttons
    16. }
    17.  
    18. void SERVER::timeout_123()
    19. {
    20.  
    21. x=x+2;
    22. y=y+2;
    23. QPixmap pix(":/t23_1.png");
    24. QGraphicsPixmapItem *pix1= scene->addPixmap(pix);
    25. ui->graphicsView->setScene(scene);
    26. pix1->setPos(x,y);
    27.  
    28.  
    29. }
    30.  
    31. void SERVER::on_pushButton_clicked()
    32. {
    33. qDebug("inserting new item");
    34. QPixmap pix2(":/pin30_red.png");
    35. QGraphicsPixmapItem *GIpix2= scene->addPixmap(pix2);
    36. ui->graphicsView->setScene(scene);
    37. GIpix2->setPos(650,150);
    38.  
    39. }
    To copy to clipboard, switch view to plain text mode 

    If i compile this code, initial timer based pixmap and pushbutton clicked pixmap will loaded onto the scene. In the Timer event Im incrementing setPos coordinated by 2 for every 1 second. Here on the scene, timer based pixmap is getting shifting in position but clear movement of image is not there somewat blurred.Any problem in the decalration?

    Thanks in Advance.
    Attached Images Attached Images

Similar Threads

  1. QGraphics View
    By Vivek1982 in forum Newbie
    Replies: 13
    Last Post: 20th December 2013, 11:26
  2. Items in QGraphics View not starting from the top.
    By penny in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2011, 13:10
  3. Qgraphics View
    By amagdy.ibrahim in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2008, 10:10
  4. QGraphics view update : Help needed
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2007, 12:54
  5. QGraphics view problem
    By kiranraj in forum Qt Programming
    Replies: 5
    Last Post: 6th March 2007, 21:28

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
  •  
Qt is a trademark of The Qt Company.