View Full Version : Method to Use The Pixmap Currently Visible Inside a QGraphicsScene/View in a Slot
brazzn
8th August 2017, 18:47
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
QGraphicsScene graphicsScene = ui->PixmapView->scene();
QGraphicsPixmapItem graphicsPixmapItem = graphicsScene.itemAt(0, 0);
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
patrik08
8th August 2017, 19:39
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/show.php/Fop+MiniScribus+XSL-Fo?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...
/* filter only item a top Zindex / zValue */
bool GraphicsScene::WakeUp( const QPointF incomming )
{
QList<QGraphicsItem *> listing = QGraphicsScene::items(incomming);
qreal thebest = 0; /* zindex on front */
for (int o=0;o<listing.size();o++) {
listing[o]->setSelected(false);
listing[o]->setFlag(QGraphicsItem::ItemIsSelectable,false);
thebest = qMax(listing[o]->zValue(),thebest);
}
/* activate item at top z-index zValue / not the down not visible!!!! */
for (int e=0;e<listing.size();e++) {
if (listing[e]->zValue() == thebest) {
listing[e]->setFlag(QGraphicsItem::ItemIsSelectable,true);
emit SelectOn(listing[e],thebest);
return true;
}
}
return false;
}
brazzn
8th August 2017, 20:07
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.
patrik08
8th August 2017, 22:35
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..
12542
https://sourceforge.net/projects/wysiwyg-edit/ qt4.8 or so
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.