Results 1 to 10 of 10

Thread: How to send the QGraphicsItem to the background of QGraphicsView

  1. #1
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default How to send the QGraphicsItem to the background of QGraphicsView

    Goal is to send few QGraphicsItem's to the QGraphicsView's background so that
    itemAt() function will not detect the items are in background on mouse click position and other mouse events are ignored.

    I understood that I can not do it with QGraphicsView::drawBackground(painter,rectf),
    some info from Qt Assistant that I need to try with QGraphicsView::drawItems(i.e. itemlayer), but who will send items list to this function? some example would be great, even if I send items to the itemlayer will the items detected by the function call itemAt()?

    Thanks/Srinivas

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

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    Can't you just hide the 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.


  3. #3
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    Thanks for your quick ans.

    I could hide using "setVisible(false)", intention is to paint the item and make visible and disable events & actions
    I tried with SetEnabled(false) but it did not work.

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

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    Why exactly do you want to do all that?
    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.


  5. #5
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    good question.

    I am doing as follows...

    I have two applications..
    In first application I have a QGraphicsView attached with QGraphicsScene, where I do some design like draw border based on vertical & harizantal values.
    Also I placed some text graphics item at the top say 'Author "xxxx"'. Now I have to steam this info into a file using QDataStream.

    In second application I need to load the stream and create the saved objects like QGraphcisRectItem & QGraphicsTextItem with values and display them in the background. what ever we create further items shall be on top of them.

    I hope I answered to you question.

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

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    I do not see how this is related to wanting an item to ignore mouse events
    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.


  7. #7
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    I am creating selection handles for the newly created graphic item there I have a constraint that I should not create a selection handle if I find a item below to it with the function itemAt(pos).
    Since those items are not send to the background they are caught by the itemAt() function.

    this is the use case.

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

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    Quote Originally Posted by battena View Post
    Since those items are not send to the background they are caught by the itemAt() function.
    Ok but WHAT items?
    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.


  9. #9
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    sorry!

    as I said in the first application I have saved some graphic items like rect, text.
    In the second application I have loaded the saved items.
    and then I draw a new rectangle graphic item above to them.

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

    Default Re: How to send the QGraphicsItem to the background of QGraphicsView

    Yes, and so? Please do not focus your description on the itemAt() method but rather say what exact behaviour you want to achieve globally. I'm assuming you know about the z-order of items and you can determine which object is "above" and which is "below" but I totally fail to see WHAT item should have its mouse events ignored and WHY (especially that it won't affect what itemAt() returns).
    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. Send qt gui application in background..
    By ajaysaini.sgvu in forum Qt Programming
    Replies: 3
    Last Post: 18th August 2012, 08:19
  2. QGraphicsItem and it's position at QGraphicsView
    By silverado in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2012, 15:28
  3. QGraphicsView, QGraphicsItem, QGraphicsScene
    By Shuchi Agrawal in forum Newbie
    Replies: 10
    Last Post: 23rd March 2011, 20:50
  4. Replies: 4
    Last Post: 23rd March 2011, 16:22
  5. (QT4.2-RC1) QGraphicsScene QGraphicsView QGraphicsItem
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 10:56

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.