Results 1 to 4 of 4

Thread: problems with qgraphicsview and qgraphicsitem

  1. #1
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default problems with qgraphicsview and qgraphicsitem

    hello, i have some problems with using opacity in qgraphicsitem.
    I have two item added to my scene. When i'mtrying to change opacity of top one, it gives me funny colors.
    http://img837.imageshack.us/i/image11y.jpg/
    Here you have example. On the left you have bottom layer, in te middle top one and on the right snapshot of the result. Opacity of the top is set to 0.5.
    Any ideas?

  2. #2
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems with qgraphicsview and qgraphicsitem

    and here is another thing:
    http://img832.imageshack.us/i/problemw.jpg/
    look at the printscreen, both view are same configures with same hint on the same scane, the only difference is that the main one(1) is not scaled like second one (2)
    and i know that the problem is only with 100% view, on upscaled or downscaled there is no problem
    have no clue what to do, please give me some hint

  3. #3
    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: problems with qgraphicsview and qgraphicsitem

    Can you show the code...hard to say without knowing what you are doing

  4. #4
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problems with qgraphicsview and qgraphicsitem

    yeah!
    Qt Code:
    1. scene=new QGraphicsScene;
    2. mainView= new QGraphicsView;
    3. (...) <-other widgets, not important
    4. mainView->setAutoFillBackground(true);
    5. mainView->setScene(scene);
    6. (...)
    7.  
    8. void MainWindow::setOp_S(int o)
    9. {
    10. qreal opac=o/100.0;
    11. scene->items()[1]->setOpacity(opac);
    12. scene->update(scene->sceneRect());
    13. mainView->update();
    14. update();
    15. }
    To copy to clipboard, switch view to plain text mode 

    and here is how i change the size of image in main view:


    Qt Code:
    1. void MainWindow::scaleImage_S(double ratio)
    2. {
    3. mainView->scale(scaleBack,scaleBack);
    4. double scaleRatio=ratio/(double)100;
    5. scaleBack=1/(double)scaleRatio;
    6. mainView->scale(scaleRatio,scaleRatio);
    7. actionZoomIn->setEnabled(pWidget->getRatio()<800);
    8. actionZoomOut->setEnabled(pWidget->getRatio()>4);
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    the problem is only when the view in main view is 100% of image, not in upscale or downscale, i'm not using any of my functions to rescale image, just build-in QGraphicsView::Scale

    after rendering the scene, no matter of size and scale, the result picture is ruined... i'm stuck...

    Fixed the problem. If someone is interested in the solution, just ask by posting here.
    Last edited by sqarpi; 23rd August 2010 at 00:41.

Similar Threads

  1. QGraphicsView, QGraphicsItem, QGraphicsScene
    By Shuchi Agrawal in forum Newbie
    Replies: 10
    Last Post: 23rd March 2011, 20:50
  2. Animation of QGraphicsItem in QGraphicsView
    By mirelon in forum Qt Programming
    Replies: 4
    Last Post: 19th December 2009, 15:25
  3. Multiple inheritance of QGraphicsView and QGraphicsItem
    By cookie1909 in forum Qt Programming
    Replies: 9
    Last Post: 15th May 2009, 18:02
  4. Replies: 2
    Last Post: 12th February 2009, 09:53
  5. (QT4.2-RC1) QGraphicsScene QGraphicsView QGraphicsItem
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 10:56

Tags for this Thread

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.