Results 1 to 3 of 3

Thread: QGraphicsScene & QGraphicsView design decisions

  1. #1
    Join Date
    Oct 2009
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene & QGraphicsView design decisions

    Hi,
    I really need help concerning my program using QGraphicsScene/View.
    My program is a cad-like software that edits some myItem derived QGraphicsItems, outputs some non-editable/non-selectable QGraphicsItems as output, and uses some control QGraphicsItems (node handles).

    My main problem is the QGraphicsScene::selectionChanged() signal behaviour.
    I want my program to control when selectionChanged can be happen. For example I have a mode that selects editable objects and applies different actions onto them. BUT there are some modes also that depend on user/mouse actions and they have to leave selection unchanged.
    So my first question is: What is the correct / clean way to stop QGraphicsScene::selectionChanged and keep selectedItems frozen? Any suggestions are welcomed.
    I tried to set a flag isSelectionChanging in my scene re-implementation , and use it to my base myItem::mousePress/Release/Move functions to not call the base class QGraphicsItem::mousePress/Release/Move when this flag is on. The thing is that it doesn't work because selectionChanged is called when the user clicks on an empty position of the screen and the current selection is cleared.


    Added after 28 minutes:


    I thought another solution. I can create a huge QGraphicsItem covering all the scene that has an empty paint() function and boundingRect() all over the scene, and has the biggest Z value and can be selected. So all the user/mouse input will go to it. I then will have to make my own myselection mechanism to update whenever I choose with the mouseEvents of this item, and make my own myselectionChanged signal emit.
    I did not try the above, cause I have concerns on how QGraphicsScene/View will treat this item and if there will be any speed issues on updating, colliditing etc.
    Any thoughts?
    Last edited by hayzel; 26th December 2014 at 13:27.

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

    Default Re: QGraphicsScene & QGraphicsView design decisions

    In my opinion you should be managing the selection yourself. You can restore the old selection when you detect it shouldn't be changing.
    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
    Oct 2009
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene & QGraphicsView design decisions

    Quote Originally Posted by wysota View Post
    In my opinion you should be managing the selection yourself. You can restore the old selection when you detect it shouldn't be changing.
    I was too frustrated messing around with custom tricks to make the selection system work as I needed to work, and I missed the obvious answer. I wrote a simple selection system over my re-implementation of QGraphicsScene according to my needs, and all work fine. Thanks.

Similar Threads

  1. QGraphicsScene & QGraphicsView help please
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 13th February 2017, 12:30
  2. QGraphicsView and QGraphicsScene
    By Molier in forum Qt Programming
    Replies: 11
    Last Post: 28th November 2010, 01:23
  3. QGraphicsView and QGraphicsScene
    By alisami in forum Qt Programming
    Replies: 8
    Last Post: 4th December 2008, 10:10
  4. Replies: 3
    Last Post: 4th April 2008, 19:51
  5. QGraphicsScene and QGraphicsView
    By sabeesh in forum Qt Programming
    Replies: 7
    Last Post: 1st August 2007, 06:59

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.