Results 1 to 7 of 7

Thread: QFrame inner rectangle

  1. #1
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QFrame inner rectangle

    Just a quick question that isn't entirely obvious to my addled brain...

    When using a QFrame that has, lets say a StyledPanel shape. To get the coordinates and sizes of the rectangle within the frame, does one obtain it with calls to QFrame.window(), QFrame.width() and QFrame.height() etc.?

    The Docs for QFrame state that a call to frameRect() will return the coordinates of the entire widget by default (with no frameRect set) but I don't think thats what I want and I'm not entirely sure how to get what I want.

    Any illumination would be appreciated.

    -Mic

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame inner rectangle

    if you want inner rectangle's size, frameWidth() and frameHeight() is your answer

  3. #3
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QFrame inner rectangle

    I see frameWidth() but I don't see frameHeight(). Are you sure?

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame inner rectangle

    frameHeight is not there. and it is obvious.

    From the docs -
    frameWidth : const int
    This property holds the width of the frame that is drawn.
    ie., it is something like the border width. subtract this from the frame rect, and you will get the inner rect

  5. #5
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame inner rectangle

    oops, my bad..i assumed that height would be there plus on second thought..i think if u call contentsRect() on frame, u'd get right values that u want..also, to make sure u r doing right, call frameRect() and frameWidth()..frameRect() should be adjusted to framewidth on contentsRect().

  6. #6
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame inner rectangle

    here is how frameRect() is calculated inside QFrame:

    Qt Code:
    1. QRect QFrame::frameRect() const
    2. {
    3. Q_D(const QFrame);
    4. QRect fr = contentsRect();
    5. if ((d->oldFrameStyle & QFrame::Shape_Mask) == QFrame::StyledPanel) {
    6. fr.adjust(-d->leftFrameWidth, -d->topFrameWidth, d->rightFrameWidth, d->bottomFrameWidth);
    7. } else
    8. fr.adjust(-d->frameWidth, -d->frameWidth, d->frameWidth, d->frameWidth);
    9. return fr;
    10. }
    To copy to clipboard, switch view to plain text mode 

    thus i believe contentsRect() should be what u need

  7. #7
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Talking Re: QFrame inner rectangle

    That makes sense. There a sentence on the QFrame documentation page that states...

    The margin between the frame and the contents of the frame can be customized with the QWidget::setContentsMargins() function.
    so the contentsRect() call should be what I need.

    Thanks!

    -Mic

Similar Threads

  1. Using a QFrame as a color selection indicator
    By KShots in forum Qt Tools
    Replies: 8
    Last Post: 14th June 2011, 23:55
  2. Rotating a rectangle about its origin
    By babu198649 in forum Newbie
    Replies: 5
    Last Post: 25th October 2008, 12:24
  3. Replies: 2
    Last Post: 5th July 2008, 19:35
  4. Display rectangle on Image
    By parmar ranjit in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2008, 13:09
  5. QFrame subclass does not reparent
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2006, 22:15

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.