Results 1 to 8 of 8

Thread: How to make bottom right & bottom left corner round of the QWidget

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default How to make bottom right & bottom left corner round of the QWidget

    Hi all

    I want to make my widgets bottom right and bottom left corner round without using QPaint

    regards
    merry
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make bottom right & bottom left corner round of the QWidget


  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to make bottom right & bottom left corner round of the QWidget

    Hi Sabeesh

    Thanx 4 sending me the link but this link is not opening

    regards
    merry
    Always Believe in Urself
    Merry

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to make bottom right & bottom left corner round of the QWidget

    Search the forum, please. Hint: search for "rounded corners".
    J-P Nurmi

  5. #5
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make bottom right & bottom left corner round of the QWidget


  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How to make bottom right & bottom left corner round of the QWidget

    Or you can use stylesheets.

  7. #7
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to make bottom right & bottom left corner round of the QWidget

    Thanx for the replies

    When I use this


    Qt Code:
    1. static QRegion roundedRect(const QRect& rect, int r)
    2. {
    3. QRegion region;
    4. // middle and borders
    5. region += rect.adjusted(r, 0, -r, 0);
    6. region += rect.adjusted(0, r, 0, -r);
    7. // top left
    8. QRect corner(rect.topLeft(), QSize(r*2, r*2));
    9. region += QRegion(corner, QRegion::Ellipse);
    10. // top right
    11. corner.moveTopRight(rect.topRight());
    12. region += QRegion(corner, QRegion::Ellipse);
    13. // bottom left
    14. corner.moveBottomLeft(rect.bottomLeft());
    15. region += QRegion(corner, QRegion::Ellipse);
    16. // bottom right
    17. corner.moveBottomRight(rect.bottomRight());
    18. region += QRegion(corner, QRegion::Ellipse);
    19. return region;
    20. }
    21.  
    22. someWidget->setMask(roundedRect(someWidget->rect(), 20));
    To copy to clipboard, switch view to plain text mode 

    All the corners of the widget get rounded , and I want only the bottom left and bottom right corners

    If in the above code ,I wont make calculations for the top left and top right corners then

    some part of the top left and top right corners is subtracted from the widget.

    regards
    merry
    Always Believe in Urself
    Merry

  8. #8
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make bottom right & bottom left corner round of the QWidget

    You're creating a mask by putting together a combination of quarter circles and rectangles. Just think about how to build that. You'll need one rectangle for the widget minus the bottom edge, so width() and height()-r. Then you'll want the bottom left and right corners as shown above, and the bottom edge between the corners (width()-2*r and height is r)

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.