Results 1 to 4 of 4

Thread: Method to Use The Pixmap Currently Visible Inside a QGraphicsScene/View in a Slot

  1. #1
    Join Date
    Aug 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Question Method to Use The Pixmap Currently Visible Inside a QGraphicsScene/View in a Slot

    I woud like to somehow gain access to the Pixmap currently displayed in my QGraphics view so that I may use QPixmap::scaled() with the scaled value corresponding to the changed value in the slider_value_changed() slot. I just can't seem to find a way to keep the Pixmap I once assigned to my GraphicsScene in scope, or any another way to access it. Below was my attempt at using GraphicsView::scene() I am not entirely sure how to implement this method though, in my example it gives me an error message "QGraphicsSCene::QGraphicsScene(const QGraphicsScene&)" is private as well as use of deleted function "QgraphicsScene(constScene&)". Any idea how I would access the Pixmap currently displayed in my QGraphicsView Widget? I'm thinking that you can only use GraphicsView::scene() if you are not using form editing (not using QGraphicsView Widgets), however this is very limited implementation and it almost seems useless.

    code inside my slider_value_changed() slot

    Qt Code:
    1. QGraphicsScene graphicsScene = ui->PixmapView->scene();
    2. QGraphicsPixmapItem graphicsPixmapItem = graphicsScene.itemAt(0, 0);
    To copy to clipboard, switch view to plain text mode 


    It might be useful if I created a class and had the scenes/pixmap be member variables. however I'm not sure how I would keep this class in scope of my slots

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Method to Use The Pixmap Currently Visible Inside a QGraphicsScene/View in a Slot

    I think your question is to set visible or not items ... is like a html layer at top or sub ...
    9 years a go i write Miniscribus... https://www.linux-apps.com/content/s...?content=67552
    and i say to controll all QList<QGraphicsItem *> to show a top or on cellar...

    all tests an app you an find on https://github.com/pehohlva/fop-miniscribus ... dinosaurier qt4.8 version...

    by...

    Qt Code:
    1. /* filter only item a top Zindex / zValue */
    2. bool GraphicsScene::WakeUp( const QPointF incomming )
    3. {
    4. QList<QGraphicsItem *> listing = QGraphicsScene::items(incomming);
    5. qreal thebest = 0; /* zindex on front */
    6. for (int o=0;o<listing.size();o++) {
    7. listing[o]->setSelected(false);
    8. listing[o]->setFlag(QGraphicsItem::ItemIsSelectable,false);
    9. thebest = qMax(listing[o]->zValue(),thebest);
    10. }
    11. /* activate item at top z-index zValue / not the down not visible!!!! */
    12. for (int e=0;e<listing.size();e++) {
    13. if (listing[e]->zValue() == thebest) {
    14. listing[e]->setFlag(QGraphicsItem::ItemIsSelectable,true);
    15. emit SelectOn(listing[e],thebest);
    16. return true;
    17. }
    18. }
    19. return false;
    20. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Method to Use The Pixmap Currently Visible Inside a QGraphicsScene/View in a Slot

    I want to access the pixmap currently being displayed in the GraphicsViewWidget/Object inside of a slider_value_changed slot. Then I want to scale the Pixmap and add it to a new scene and then add that scene to the graphicsViewWidget/object. The only issue I have is accessing the pixmap that was created in a different slot because it is out of scope.

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Method to Use The Pixmap Currently Visible Inside a QGraphicsScene/View in a Slot

    That's what I say above ... you have to have good control of child item to enable edit or chance state by double click or wathever ..

    Anatomy from Controll: start chance stop this is a proper handling from your graphicswidget ....

    I quote:
    the anatomy of control. This is a cycle of action. There is continue (persist) on the middle of the curve and other cycles within cycles of action, but the most important factors are start, change, and stop. These three parts of control are run flat individually. Then pick up the other part of the cycle and run that flat in this order: we run change flat, and then run start very flat and then we run stop flat.

    Knowledge of good control exists in the past 10'000 years first buddism after scientologist..


    You need a controll system from your graphicswidget... you have this ... code?

    Edit this is wath i mean..

    miniscri.jpg

    https://sourceforge.net/projects/wysiwyg-edit/ qt4.8 or so
    Last edited by patrik08; 8th August 2017 at 22:46.

Similar Threads

  1. Replies: 2
    Last Post: 15th April 2016, 12:34
  2. get currently visible items in QGraphicsScene
    By Santa.fat in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2015, 21:14
  3. Replies: 4
    Last Post: 27th October 2015, 13:42
  4. Replies: 0
    Last Post: 7th January 2010, 23:03
  5. QGLWidget inside QGraphicsScene/View
    By h123 in forum Qt Programming
    Replies: 3
    Last Post: 10th January 2009, 09:46

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.