PDA

View Full Version : Using QList<QGraphicsItem*>



brazzn
9th August 2017, 03:24
I am using a developer defined QGraphicsScene pointer from the "dialog/mainwindow" class called wavesScene to return a QList of QGraphicsItem*'s using QGraphicsScene::items. Something seems to be wrong with my syntax, it says that the list "graphicsItemList" is never used/declared.
Here is my code, any ideas as to how I would properly implement this methodology


relevant code inside mainwindow/segyView.h


QGraphicsScene *wavesScene;
Constructor code *I think, may be called something different
SEGYView::SEGYView(QWidget *parent)
:QMainWindow(parent),
ui(new Ui::SEGYView)
{
ui->setupUi(this);
wavesScene = new QGraphicsScene(this);
ui->PixmapView->setScene(wavesScene);
}


Code inside slider_value_changed() slot


QList<QGraphicsItem*> graphicsItemList(wavesScene->items());
QGraphicsPixmapItem pixmapItem(graphicsItemList.at(0));
QPixmap wavesPixmap = pixmapItem.pixmap();
QPixmap wavesPixmapScaled = wavesPixmap.scaled((newSliderValue*INITIAL_WAVES_P IXMAP_X_SIZE), 1250);
pixmapItem.setPixmap((wavesPixmapScaled));
wavesScene->addItem(&pixmapItem);
relevant code inside actionOpen on triggered() slot
wavesScene->addItem(pixmapGraphicsItem);
ui->PixmapView->setScene(wavesScene);


Error is "graphicsItemList" was not declared in this scope QGraphicsPixmapItem* pixmapItem = graphicsItemList.at(0);
^

d_stranz
9th August 2017, 17:12
You need to show us your real code, not "relevant" lines you've copied and pasted from who knows where. Copy and paste the full methods where you are getting the errors. Code without context is useless for helping you solve the problem.