Results 1 to 12 of 12

Thread: QGraphicsScene update?

  1. #1
    Join Date
    Apr 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsScene update?

    Hi,

    In a project I'm currently working on, I've encountered a problem, I'll describe it the best I can:

    There is a QGraphicsView whit a QGraphicsScene in it, wherein I'm adding some QGraphicItems, that is working fine, even when I add a QWidget (resulting in a QGraphicsProxyWidget) it shows up perfectly in de scene (the QWidget I'm adding is a second QGraphicsView).

    The problem however occurs when I try to move or scale te QGraphicsProxyWidget, it seems that the shape() or the boundingRect() isn't updating or something.
    I tried some things like update(), setGeometryChange() etc, but nothing is working...

    Can someone help me?
    Thanks
    Gurdt

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene update?

    As far as I know embedding a graphics view inside graphics view doesn't work well. I don't know whether Qt4.5 introduced improvements in the matter but previous versions had problems with such configuration. Moving() a widget item won't change its boundingRect() or shape() though and that's ok. Can we see the code you are using?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene update?

    Qt Code:
    1. class Bord : public QGraphicsView
    2. {
    3. Q_OBJECT
    4. ...
    5. private:
    6. QGraphicsScene* m_bordScene;
    7. ...
    8. }
    9.  
    10. ...
    11.  
    12. //interfaceScene is a QGraphicsScene
    13. QGraphicsProxyWidget *m_bord = interfaceScene->addWidget( new Bord());
    14. m_bord->moveBy(40, 100);
    To copy to clipboard, switch view to plain text mode 
    so the QGraphicsView is added into a QGraphicsScene, resulting in a QGraphicsProxyWidget.

    Here is a screenshot of the interfaceScene BEFORE moving: http://home.scarlet.be/gertnelissen/...foreMoving.jpg
    Here is a screenshot AFTER: http://home.scarlet.be/gertnelissen/...fterMoving.jpg

    information: the white rectangle is the size of a Bord (QGraphicsScene), there are some blocks in it (it's a puzzle), these blocks are, as you can see, not drawed well after moving

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsScene update?

    Hi,

    you can try setPos() to move your item.

  5. #5
    Join Date
    Apr 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene update?

    Sorry it has no effect, what is pretty obvious becouse moveBy is built on setPos I guess

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsScene update?

    Hi,

    I'am ok with that but sometimes it could be helpful to try different methods. If you didn't try, have it your way

    by the way, did you add your item to the scene right? I see addWidget there maybe you should replace it with addItem?

  7. #7
    Join Date
    Apr 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene update?

    been there done that
    I've tried all manners to update a scene, and all manners to add a widget into a scene...

    Maybe it's not meant to add a QGraphicsView in another?

    (I've tried other QGraphicsProxyWidget and then it works just fine, the problem seems to occur only when I try to add another QGraphicsView)

  8. #8
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsScene update?

    Great than

  9. #9
    Join Date
    Apr 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene update?

    Sorry if you misunderstood me, but I still haven't find any solution,
    I really need to add a QGraphicsView into another QGraphicsView, I still get the error...

  10. #10
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGraphicsScene update?

    Ok,

    I think you know one scene can be observed by several views but your style seems really wierd (adding another QGraphicsView inside the QGraphicsScene which inside another QGraphicsView).

    Hımm, you may try to add a new scene in to your QGraphicsProxyWidget.

    You can also send me your source code if possible. I can check it out.

  11. #11
    Join Date
    Apr 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene update?

    The reason why I'm adding a view to another scene is because my bord (means puzzle) is a class on its own, accidentally using a scene+view itself.

    My interface is a large scene/view, and graphicsitems and buttons are added to that scene. Just like that, I'm adding a Bord (puzzle) class, which is a GraphicsView itself.

    Since the puzzle uses drag and drop, I can't see any other way to implement it.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene update?

    Quote Originally Posted by Gurdt View Post
    The reason why I'm adding a view to another scene is because my bord (means puzzle) is a class on its own, accidentally using a scene+view itself.
    You should be able to rewrite it easily so that the internal scene is replaced by a graphics item with all the functionality retained and the scene items become child items of the "board" item.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Problem in QProgressBar update
    By nikhilqt in forum Qt Programming
    Replies: 0
    Last Post: 10th March 2009, 10:20
  2. Replies: 0
    Last Post: 5th March 2009, 06:54
  3. Qt Update project - Opinions wanted
    By pvdk in forum Qt Programming
    Replies: 0
    Last Post: 8th November 2008, 08:41
  4. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 09:42
  5. Replies: 1
    Last Post: 26th December 2007, 10:58

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.