Results 1 to 4 of 4

Thread: Positioning QGraphicsWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Posts
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Positioning QGraphicsWidget

    Ok, after waking up this morning and seeing no replies, I did some experiment.

    I did not positioned the ButtonWidget instance after adding it to the scene and the answer was right there on the screen!

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Positioning QGraphicsWidget

    What is your ButtonWidget::boundingRect() like?

    Remember that geometry is relative to position. And position is relative to parent item.

  3. #3
    Join Date
    Jun 2007
    Posts
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Positioning QGraphicsWidget

    scascio, I have already solved this problem but I'll answer your question anyway.

    In the first sample code it is:

    Qt Code:
    1. QRectF ButtonWidget::boundingRect()
    2. {
    3. return QRectF(0, 0, 50, 50);
    4. }
    To copy to clipboard, switch view to plain text mode 

    In the second:

    Qt Code:
    1. QRectF ButtonWidget::boundingRect()
    2. {
    3. return QRectF(-20, -20, 50, 50);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Edit: spelling correction

Similar Threads

  1. QGraphicsRectItem positioning problem
    By gufeatza in forum Qt Programming
    Replies: 3
    Last Post: 5th September 2009, 00:24
  2. QGraphicsWidget - How does it work?
    By been_1990 in forum Qt Programming
    Replies: 2
    Last Post: 31st July 2009, 13:15
  3. QGraphicsWidget vs. QGraphicsRectItem
    By Bill in forum Newbie
    Replies: 3
    Last Post: 27th July 2009, 09:02
  4. QwebPage within a QGraphicsWidget
    By Osprey in forum Qt Programming
    Replies: 0
    Last Post: 16th June 2009, 17:32
  5. Replies: 1
    Last Post: 22nd October 2007, 02:04

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.