Results 1 to 10 of 10

Thread: Drawing on QGraphicsItem.

  1. #1
    Join Date
    Jul 2011
    Location
    Pune, India
    Posts
    21
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Drawing on QGraphicsItem.


    Is it possible to draw a grid on a QGraphicsItem?
    And
    Is it possible to resize that grid with the help of any events?

    Could use all the help i get.
    thnx.

  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: Drawing on QGraphicsItem.

    Quote Originally Posted by ommharidaas View Post
    Is it possible to draw a grid on a QGraphicsItem?
    Yes.

    Is it possible to resize that grid with the help of any events?
    Yes.
    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
    Jul 2011
    Location
    Pune, India
    Posts
    21
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing on QGraphicsItem.


    Could u show some code snippets or point me in the direction as to how to go about doin so?
    I want to draw a resizable grid on QGraphicsItem and be able to place small icons in grid cells.
    Thanks for ur response wysota!


  4. #4
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: Drawing on QGraphicsItem.

    Is there a specific reason why you don't want to use, for example, QGraphicsScene::drawBackground() to draw the grid and then place the items as individual QGraphicsItems on the scene?

  5. #5
    Join Date
    Jul 2011
    Location
    Pune, India
    Posts
    21
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing on QGraphicsItem.

    Quote Originally Posted by helloworld View Post
    Is there a specific reason why you don't want to use, for example, QGraphicsScene::drawBackground() to draw the grid and then place the items as individual QGraphicsItems on the scene?

    No, coz thats not what I want to achieve.
    I have set a QGraphicsScene as a bgrnd, and for some specific reasons, I want to add an QGraphicsItem on that using
    scene->addItem(item).
    And I want to b able to draw d grid on that item and not on the scene. I hope I hv put down my doubt clearly.
    Can use all the help.
    Thnx.

  6. #6
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: Drawing on QGraphicsItem.

    If this suits your needs, the easiest way is probaby to create a subclass of QGraphicsItem, reimplement paint() and simply draw the grid from there.

  7. #7
    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: Drawing on QGraphicsItem.

    Make your grid a child item of the item you want it to be drawn on. Make the icons child items of the grid 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.


  8. #8
    Join Date
    Jul 2011
    Location
    Pune, India
    Posts
    21
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing on QGraphicsItem.

    Quote Originally Posted by wysota View Post
    Make your grid a child item of the item you want it to be drawn on. Make the icons child items of the grid item.

    I have managed to draw a grid on QGraphicsSvgItem.
    Now what i want to do is grab a lower right corner of that grid with mouse click and resize it.
    if you could tell me how should i go about it !
    Should i try to handle a resizeEvent or make the grid shrik and expand on mouseClickDrag or anything like that??
    Please shed some light on this aspect as well.
    Thanks.

  9. #9
    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: Drawing on QGraphicsItem.

    If you want me to guide you step by step to implement your program then that's not going to happen. Learn a tool first before you start using it.
    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.


  10. #10
    Join Date
    Jul 2011
    Location
    Pune, India
    Posts
    21
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing on QGraphicsItem.

    Quote Originally Posted by wysota View Post
    If you want me to guide you step by step to implement your program then that's not going to happen. Learn a tool first before you start using it.
    NO...Just a hint would have been nice! i dint ask you to write a god damm code for me!
    Issue was solved by the way.
    thank you all for all the help!

Similar Threads

  1. Drawing in QML
    By JeffC in forum Newbie
    Replies: 10
    Last Post: 10th June 2011, 18:25
  2. Replies: 7
    Last Post: 29th November 2010, 19:20
  3. Drawing 3d pie
    By toutarrive in forum Qt Programming
    Replies: 3
    Last Post: 5th September 2009, 16:21
  4. Casting QGraphicsItem child from QGraphicsItem
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 29th August 2008, 15:37
  5. Replies: 2
    Last Post: 28th June 2008, 16:31

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.