Results 1 to 2 of 2

Thread: Using QList<QGraphicsItem*>

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

    Default Using QList<QGraphicsItem*>

    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

    Qt Code:
    1. QGraphicsScene *wavesScene;
    2. Constructor code *I think, may be called something different
    3. SEGYView::SEGYView(QWidget *parent)
    4. :QMainWindow(parent),
    5. ui(new Ui::SEGYView)
    6. {
    7. ui->setupUi(this);
    8. wavesScene = new QGraphicsScene(this);
    9. ui->PixmapView->setScene(wavesScene);
    10. }
    To copy to clipboard, switch view to plain text mode 

    Code inside slider_value_changed() slot

    Qt Code:
    1. QList<QGraphicsItem*> graphicsItemList(wavesScene->items());
    2. QGraphicsPixmapItem pixmapItem(graphicsItemList.at(0));
    3. QPixmap wavesPixmap = pixmapItem.pixmap();
    4. QPixmap wavesPixmapScaled = wavesPixmap.scaled((newSliderValue*INITIAL_WAVES_PIXMAP_X_SIZE), 1250);
    5. pixmapItem.setPixmap((wavesPixmapScaled));
    6. wavesScene->addItem(&pixmapItem);
    7. relevant code inside actionOpen on triggered() slot
    8. wavesScene->addItem(pixmapGraphicsItem);
    9. ui->PixmapView->setScene(wavesScene);
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using QList<QGraphicsItem*>

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 13th March 2014, 19:11
  2. QList QgraphicsItem pos x value returns 0
    By devdon in forum Qt Programming
    Replies: 10
    Last Post: 20th September 2011, 08:46
  3. Qlist<QLabel *> in Qlist<QAction*>
    By Naahmi in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2011, 08:53
  4. Replies: 4
    Last Post: 20th August 2010, 13:54
  5. Whats wrong with QList<QGraphicsItem>
    By rubenvb in forum Newbie
    Replies: 6
    Last Post: 22nd January 2010, 19:01

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.