Results 1 to 5 of 5

Thread: Hiding QGraphicsRectItems

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Post Hiding QGraphicsRectItems

    I am trying to use hide() show() or setVisible(false) function with QGraphicsRectItem objects. I can display them on the scene but no way I can do anything to hide them from screen. I have initialised them in the following code :

    Qt Code:
    1. rectItems = new QVector<QGraphicsRectItem *>();
    2.  
    3. for (int raw=0;raw<this->qElementsHeight;raw++){
    4. for(int column=0;column<this->qElementsWidth;column++){
    5. QRectF rectF( raw*48, column*48, 48, 48 );
    6. rect->setPen(pen);
    7. rectItems->push_back(rect);
    8. rectItems->last()->setVisible(false);
    9. this->addRect(rectItems->last()->rect(),pen);
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    then tried to use hide() in a slot function:

    Qt Code:
    1. for (int c=0;c<rectItems->count();c++){
    2. QGraphicsRectItem *temp =rectItems->at(c);
    3. if(bGrid) {
    4. //temp->setVisible(true);
    5. //temp->show();
    6. rectItems[0].at(c)->setVisible(true);
    7. }
    8. else {
    9. //temp->setVisible(false);
    10. //temp->hide();
    11. rectItems[0].at(c)->setVisible(false);
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    none of it hides the rectangles in the scene. Is there a way of hiding them ?
    Last edited by ddze; 28th January 2011 at 23:52. Reason: change the title

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
  •  
Qt is a trademark of The Qt Company.